#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QProcess>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
#ifdef RUN_IN_BOARD
    QApplication::setOverrideCursor(Qt::BlankCursor);
#endif
    this->setWindowFlags(Qt::FramelessWindowHint);
    setAttribute(Qt::WA_TranslucentBackground, true);
    GlobalConfig::InitDDULog();
    GlobalConfig::writeLog("HFL8 DDU start..");
    readGlobalConfigFiles();
    InitWidgets();
    LocalTest();
    GlobalConfig::ReadLast200Faults();
    tcms_event_history_->updateHistory();
    cur_subpage_ = Page_Operation;
    cur_cctv_subpage_ = Page_CCTV_RealTimeMonitor;
    cycle_task_timer_ = new QTimer(this);
    connect(cycle_task_timer_,SIGNAL(timeout()),this,SLOT(slot_CycleTask()));
    cycle_task_timer_->setInterval(500);
#ifdef RUN_IN_BOARD
    hwDriver = new HardwareDriver(this);
    stopbeep();
    dataHandler = new DataParser(new TRDPThread);
    startCom();
    cycle_task_timer_->start();
#endif
    has_not_sync_time_ever_ = true;
    GlobalConfig::writeLog("HFL8 DDU init end..");
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::readGlobalConfigFiles()
{
    int ret = 0;
    ret = GlobalConfig::readConfigFile("./config.ini");
    if(ret < 0)
    {
        GlobalConfig::writeLog("通用配置文件读取错误！");
        exit(0);
    }

    ret = GlobalConfig::readRecvTRDPDataFile("./TRDPComCfgR.csv");
    if(ret < 0)
    {
        GlobalConfig::writeLog("TRDP接收配置文件读取错误！");
        exit(0);
    }

    ret = GlobalConfig::readSendTRDPDataFile("./TRDPComCfgW.csv");
    if(ret < 0)
    {
        GlobalConfig::writeLog("TRDP发送配置文件读取错误！");
        exit(0);
    }

    ret = GlobalConfig::readRouteFile("./StationList.csv");
    if(ret < 0)
    {
        GlobalConfig::writeLog("线路站点信息文件读取错误！");
        exit(0);
    }

    ret = GlobalConfig::readSpecialMessageFile("./SpecialMessage.csv");
    if(ret < 0)
    {
        GlobalConfig::writeLog("紧急广播配置文件读取错误！");
        exit(0);
    }
    ret = GlobalConfig::parseOperationFile("logOperationFile");
}

void MainWindow::sendDDUSWVer()
{
#ifdef RUN_IN_BOARD
    QString ver = qApp->applicationVersion();
    uint ver0 = ver.section('.', 0, 0).toUInt();
    uint ver1 = ver.section('.', 1, 1).toUInt();
    uint ver2 = ver.section('.', 2, 2).toUInt();
    dataHandler->setSendVarValue(0, 2,0,((ver0<<12)+(ver1<<8)+ver2));
#endif
}

void MainWindow::InitWidgets()
{
    toptitle_ = new TopTitle(this);
    toptitle_->move(TopTitlePOS);
    connect(toptitle_,SIGNAL(showOperationHelp(int)),this,SLOT(slot_Show_Page(int)));

    mini_train_ = new MiniTrain(this);
    mini_train_->move(TCMSPagePOS);
    mini_train_->hide();

    PageInfo pageinfo = { NULL, ""};
    //Page operation
    tcms_operation_ = new PageOperation(this);
    tcms_operation_->move(TCMSPagePOS);
    pageinfo = {tcms_operation_,"运行界面"};
    map_pageindex_pageinfo_.insert(Page_Operation,pageinfo);
    connect(tcms_operation_,SIGNAL(signal_show_operation_page(int)),this,SLOT(slot_Show_Page(int)));
    connect(tcms_operation_->atc_page()->Menu(),SIGNAL(signal_atc_test(uint8_t)),this,SLOT(slot_atc_test(uint8_t)));

    tcms_speed_limit_ = new PageSpdLmtReason(this);
    tcms_speed_limit_->move(TCMSPagePOS);
    tcms_speed_limit_->hide();
    pageinfo = {tcms_speed_limit_,"限速提示"};
    map_pageindex_pageinfo_.insert(Page_Operation_SpdLimit,pageinfo);
    connect(tcms_speed_limit_,SIGNAL(signal_go_back()),this,SLOT(slot_Go_Back()));
    connect(tcms_speed_limit_,SIGNAL(signal_speedlimt_act(bool)),tcms_operation_,SLOT(slotSpeedLimitBtnStat(bool)));

    tcms_eb_reason_ = new PageEBTrigReason(this);
    tcms_eb_reason_->move(TCMSPagePOS);
    tcms_eb_reason_->hide();
    pageinfo = {tcms_eb_reason_,"紧急制动"};
    map_pageindex_pageinfo_.insert(Page_Operation_EBTrig,pageinfo);
    connect(tcms_eb_reason_,SIGNAL(signal_go_back()),this,SLOT(slot_Go_Back()));
    connect(tcms_eb_reason_,SIGNAL(signal_EB_trig(bool)),tcms_operation_,SLOT(slotEBTrigBtnStat(bool)));

    tcms_bypass_ = new PageBypass(this);
    tcms_bypass_->move(TCMSPagePOS);
    tcms_bypass_->hide();
    pageinfo = {tcms_bypass_,"旁路信息"};
    map_pageindex_pageinfo_.insert(Page_Operation_Bypass,pageinfo);
    connect(tcms_bypass_,SIGNAL(signal_go_back()),this,SLOT(slot_Go_Back()));
    connect(tcms_bypass_,SIGNAL(signal_one_bypass_act(bool)),tcms_operation_,SLOT(slotBypassBtnStat(bool)));

    tcms_self_test_ = new PageSelfTest(this);
    tcms_self_test_->move(TCMSPagePOS);
    tcms_self_test_->hide();
    pageinfo = {tcms_self_test_,"自检状态"};
    map_pageindex_pageinfo_.insert(Page_Operation_SelfTest,pageinfo);
    connect(tcms_self_test_,SIGNAL(signal_go_back()),this,SLOT(slot_Go_Back()));

    tcms_traction_block_ = new PageTractionBlock(this);
    tcms_traction_block_->move(TCMSPagePOS);
    tcms_traction_block_->hide();
    pageinfo = {tcms_traction_block_,"牵引封锁"};
    map_pageindex_pageinfo_.insert(Page_Operation_TracBlock,pageinfo);
    connect(tcms_traction_block_,SIGNAL(signal_go_back()),this,SLOT(slot_Go_Back()));
    connect(tcms_traction_block_,SIGNAL(signal_one_tbtrig_act(bool)),tcms_operation_,SLOT(slotTracBlockBtnStat(bool)));

    tcms_operation_help_ = new PageHelpOperation(this);
    tcms_operation_help_->move(TCMSPagePOS);
    tcms_operation_help_->hide();
    pageinfo = {tcms_operation_help_,"帮助"};
    map_pageindex_pageinfo_.insert(Page_Operation_Help,pageinfo);
    connect(tcms_operation_help_,SIGNAL(signal_go_back()),this,SLOT(slot_Go_Back()));

    //Page vehicles
    tcms_traction_stat_ = new PageTraction(this);
    tcms_traction_stat_->move(TCMSPagePOS2);
    tcms_traction_stat_->hide();
    pageinfo = {tcms_traction_stat_,"牵引系统"};
    map_pageindex_pageinfo_.insert(Page_Vehcile_Traction,pageinfo);

    tcms_brake_stat_ = new PageBrake(this);
    tcms_brake_stat_->move(TCMSPagePOS2);
    tcms_brake_stat_->hide();
    pageinfo = {tcms_brake_stat_,"制动系统"};
    map_pageindex_pageinfo_.insert(Page_Vehcile_Brake,pageinfo);

    tcms_brake_stat_ = new PageBrake(this);
    tcms_brake_stat_->move(TCMSPagePOS2);
    tcms_brake_stat_->hide();
    pageinfo = {tcms_brake_stat_,"制动系统"};
    map_pageindex_pageinfo_.insert(Page_Vehcile_Brake,pageinfo);

    tcms_aux_stat_ = new PageAux(this);
    tcms_aux_stat_->move(TCMSPagePOS2);
    tcms_aux_stat_->hide();
    pageinfo = {tcms_aux_stat_,"辅助系统"};
    map_pageindex_pageinfo_.insert(Page_Vehcile_Aux,pageinfo);

    tcms_battery_stat_ = new PageBattery(this);
    tcms_battery_stat_->move(TCMSPagePOS2);
    tcms_battery_stat_->hide();
    pageinfo = {tcms_battery_stat_,"蓄电池系统"};
    map_pageindex_pageinfo_.insert(Page_Vehcile_Battery,pageinfo);

    tcms_fire_stat_ = new PageFire(this);
    tcms_fire_stat_->move(TCMSPagePOS);
    tcms_fire_stat_->hide();
    pageinfo = {tcms_fire_stat_,"火灾系统"};
    map_pageindex_pageinfo_.insert(Page_Vehcile_Fire,pageinfo);
    connect(tcms_fire_stat_,SIGNAL(signal_ResetFireAlarm(bool)),this,SLOT(slot_ResetFireAlarm(bool)));

    tcms_pecu_stat_ = new PagePECU(this);
    tcms_pecu_stat_->move(TCMSPagePOS);
    tcms_pecu_stat_->hide();
    pageinfo = {tcms_pecu_stat_,"紧急对讲"};
    map_pageindex_pageinfo_.insert(Page_Vehcile_PECU,pageinfo);

    tcms_vehicle_side_navi_ = new PageVehicleSideNavi(this);
    tcms_vehicle_side_navi_->move(SideNaviPOS);
    tcms_vehicle_side_navi_->hide();
    connect(tcms_vehicle_side_navi_,SIGNAL(signal_show_vehicle_page(int)),this,SLOT(slot_Show_Page(int)));

    //Page HVAC
    tcms_hvac_ = new PageHvac(this);
    tcms_hvac_->move(TCMSPagePOS2);
    tcms_hvac_->hide();
    pageinfo = {tcms_hvac_,"空调控制"};
    map_pageindex_pageinfo_.insert(Page_HVAC,pageinfo);
    connect(tcms_hvac_,SIGNAL(signal_SendHvacMode(int,bool)),this,SLOT(slot_SendHvacMode(int,bool)));
    connect(tcms_hvac_,SIGNAL(signal_HvacTemp(int,int)),this,SLOT(slot_HvacTemp(int,int)));
    connect(tcms_hvac_,SIGNAL(signal_OpenNADamper(bool)),this,SLOT(slot_OpenNADamper(bool)));
    connect(tcms_hvac_,SIGNAL(signal_CloseNADamper(bool)),this,SLOT(slot_CloseNADamper(bool)));

    //Page pis setting
    tcms_pis_side_navi_ = new PagePisSideNavi(this);
    tcms_pis_side_navi_->move(SideNaviPOS1);
    tcms_pis_side_navi_->hide();
    connect(tcms_pis_side_navi_,SIGNAL(signal_show_vehicle_page(int)),this,SLOT(slot_Show_Page(int)));

    tcms_pis_mode_set_ = new PagePisModeSetting(this);
    tcms_pis_mode_set_->move(TCMSPagePOS);
    tcms_pis_mode_set_->hide();
    pageinfo = {tcms_pis_mode_set_,"广播模式\n设置"};
    map_pageindex_pageinfo_.insert(Page_PIS_ModeSetting,pageinfo);
    connect(tcms_pis_mode_set_,SIGNAL(signal_change_direction(uint8_t)),this,SLOT(slot_change_direction(uint8_t)));
    connect(tcms_pis_mode_set_,SIGNAL(signal_set_pis_mode(int,bool)),this,SLOT(slot_set_pis_mode(int,bool)));

    tcms_pis_station_set_ = new PagePisStationSelect(this);
    tcms_pis_station_set_->move(TCMSPagePOS);
    tcms_pis_station_set_->hide();
    pageinfo = {tcms_pis_station_set_,"站点选择"};
    map_pageindex_pageinfo_.insert(Page_PIS_StationSelect,pageinfo);
    connect(tcms_pis_station_set_,SIGNAL(signal_PisStationSet(bool)),this,SLOT(slot_PisStationSet(bool)));
    connect(tcms_pis_station_set_,SIGNAL(signal_DepartComfirm(bool)),this,SLOT(slot_DepartComfirm(bool)));

    tcms_pis_skip_station_set_ = new PagePisSkipStationSelect(this);
    tcms_pis_skip_station_set_->move(TCMSPagePOS);
    tcms_pis_skip_station_set_->hide();
    pageinfo = {tcms_pis_skip_station_set_,"越站设置"};
    map_pageindex_pageinfo_.insert(Page_PIS_SkipStationSelect,pageinfo);
    connect(tcms_pis_mode_set_,SIGNAL(signal_change_direction(uint8_t)),tcms_pis_station_set_,SLOT(ChangeLineInfo(uint8_t)));
    connect(tcms_pis_mode_set_,SIGNAL(signal_change_direction(uint8_t)),tcms_pis_skip_station_set_,SLOT(ChangeLineInfo(uint8_t)));
    connect(tcms_pis_skip_station_set_,SIGNAL(signal_SkipStationActive(bool)),this,SLOT(slot_SkipStationActive(bool)));
    connect(tcms_pis_skip_station_set_,SIGNAL(signal_SkipStationID(uint32_t)),this,SLOT(slot_SkipStationID(uint32_t)));

    tcms_pis_em_broadcast_set_ = new PageEmBroadCast(this);
    tcms_pis_em_broadcast_set_->move(TCMSPagePOS);
    tcms_pis_em_broadcast_set_->hide();
    pageinfo = {tcms_pis_em_broadcast_set_,"紧急广播"};
    map_pageindex_pageinfo_.insert(Page_PIS_EmBroadCastSetting,pageinfo);
    connect(tcms_pis_em_broadcast_set_,SIGNAL(signal_EmBroadCastOnceValid(bool)),this,SLOT(slot_EmBroadCastOnceValid(bool)));
    connect(tcms_pis_em_broadcast_set_,SIGNAL(signal_EmBroadCastLoopValid(bool)),this,SLOT(slot_EmBroadCastLoopValid(bool)));

    tcms_pis_volume_set_ = new PageSetVolume(this);
    tcms_pis_volume_set_->move(TCMSPagePOS);
    tcms_pis_volume_set_->hide();
    pageinfo = {tcms_pis_volume_set_,"音量调节"};
    map_pageindex_pageinfo_.insert(Page_PIS_VolumeSetting,pageinfo);

    //Page setting
    tcms_setting_side_navi_ = new PageSettingSideNavi(this);
    tcms_setting_side_navi_->move(SideNaviPOS1);
    tcms_setting_side_navi_->hide();
    connect(tcms_setting_side_navi_,SIGNAL(signal_show_setting_page(int)),this,SLOT(slot_Show_Page(int)));

    tcms_setting_reset_pce_siv_ = new PageRestPCESIV(this);
    tcms_setting_reset_pce_siv_->move(TCMSPagePOS);
    tcms_setting_reset_pce_siv_->hide();
    pageinfo = {tcms_setting_reset_pce_siv_,"牵引辅助\n复位"};
    map_pageindex_pageinfo_.insert(Page_Setting_ResetPCESIV,pageinfo);
    connect(tcms_setting_reset_pce_siv_,SIGNAL(signal_ResetPCE(bool)),this,SLOT(slot_ResetPCE(bool)));
    connect(tcms_setting_reset_pce_siv_,SIGNAL(signal_ResetACE(bool)),this,SLOT(slot_ResetACE(bool)));

    tcms_setting_backlight_set_ = new PageLightSetting(this);
    tcms_setting_backlight_set_->move(TCMSPagePOS);
    tcms_setting_backlight_set_->hide();
    pageinfo = {tcms_setting_backlight_set_,"背光调节"};
    map_pageindex_pageinfo_.insert(Page_Setting_BackLight,pageinfo);
    connect(tcms_setting_backlight_set_,SIGNAL(SetBackLightValue(int)),this,SLOT(slot_SetBackLight(int)));

    //Page event
    tcms_event_side_navi_ = new PageEventSideNavi(this);
    tcms_event_side_navi_->move(SideNaviPOS1);
    tcms_event_side_navi_->hide();
    connect(tcms_event_side_navi_,SIGNAL(signal_show_event_page(int)),this,SLOT(slot_Show_Page(int)));
    connect(tcms_event_side_navi_,SIGNAL(signal_show_event_hint()),this,SLOT(slot_Show_EventHint()));

    tcms_event_current_ = new PageCurrentEvents(this);
    tcms_event_current_->move(TCMSPagePOS);
    tcms_event_current_->hide();
    pageinfo = {tcms_event_current_,"现存故障"};
    map_pageindex_pageinfo_.insert(Page_Event_Cur,pageinfo);

    tcms_event_history_ = new PageHisEvents(this);
    tcms_event_history_->move(TCMSPagePOS);
    tcms_event_history_->hide();
    pageinfo = {tcms_event_history_,"故障履历"};
    map_pageindex_pageinfo_.insert(Page_Event_His,pageinfo);

    //Page Maintenance
    tcms_maint_login_ = new PageLogin(this);
    tcms_maint_login_->move(TCMSPagePOS);
    tcms_maint_login_->hide();
    pageinfo = {tcms_maint_login_,"登录"};
    map_pageindex_pageinfo_.insert(Page_Maint_Login,pageinfo);
    connect(tcms_maint_login_,SIGNAL(loginOk()),this,SLOT(slot_LoginSuccess()));

    tcms_maint_menu_ = new PageMaintMenu(this);
    tcms_maint_menu_->move(TCMSPagePOS);
    tcms_maint_menu_->hide();
    pageinfo = {tcms_maint_menu_,"维护"};
    map_pageindex_pageinfo_.insert(Page_Maint_Menu,pageinfo);
    connect(tcms_maint_menu_,SIGNAL(signal_show_maint_page(int)),this,SLOT(slot_Show_Page(int)));

    tcms_maint_time_set_ = new PageTimeSet(this);
    tcms_maint_time_set_->move(TCMSPagePOS);
    tcms_maint_time_set_->hide();
    pageinfo = {tcms_maint_time_set_,"时间设置"};
    map_pageindex_pageinfo_.insert(Page_Maint_TimeSet,pageinfo);
    connect(tcms_maint_time_set_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));
    connect(tcms_maint_time_set_,SIGNAL(signal_TimeSetValid(bool)),this,SLOT(slot_TimeSet(bool)));

    tcms_maint_wheel_set_ = new PageWheelSet(this);
    tcms_maint_wheel_set_->move(TCMSPagePOS);
    tcms_maint_wheel_set_->hide();
    pageinfo = {tcms_maint_wheel_set_,"轮径设置"};
    map_pageindex_pageinfo_.insert(Page_Maint_WheelSet,pageinfo);
    connect(tcms_maint_wheel_set_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));
    connect(tcms_maint_wheel_set_,SIGNAL(signal_ProWheelSetValid(bool)),this,SLOT(slot_ProWheelSetValid(bool)));
    connect(tcms_maint_wheel_set_,SIGNAL(signal_BrkWheelSetValid(bool)),this,SLOT(slot_BrkWheelSetValid(bool)));

    tcms_maint_trainnum_set_ = new PageTrainNumSet(this);
    tcms_maint_trainnum_set_->move(TCMSPagePOS);
    tcms_maint_trainnum_set_->hide();
    pageinfo = {tcms_maint_trainnum_set_,"列车号设置"};
    map_pageindex_pageinfo_.insert(Page_Maint_TrainNumSet,pageinfo);
    connect(tcms_maint_trainnum_set_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));
    connect(tcms_maint_trainnum_set_,SIGNAL(signal_LineSetValid(bool)),this,SLOT(slot_LineSet(bool)));
    connect(tcms_maint_trainnum_set_,SIGNAL(signal_TrainIDSetValid(bool)),this,SLOT(slot_TrainIDSet(bool)));

    tcms_maint_password_set_ = new PagePasswordSet(this);
    tcms_maint_password_set_->move(TCMSPagePOS);
    tcms_maint_password_set_->hide();
    pageinfo = {tcms_maint_password_set_,"密码设置"};
    map_pageindex_pageinfo_.insert(Page_Maint_PasswordSet,pageinfo);
    connect(tcms_maint_password_set_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));

    tcms_maint_lcuboard_switch_ = new PageLCUBoardSwitch(this);
    tcms_maint_lcuboard_switch_->move(TCMSPagePOS);
    tcms_maint_lcuboard_switch_->hide();
    pageinfo = {tcms_maint_lcuboard_switch_,"LCU板卡\n强制"};
    map_pageindex_pageinfo_.insert(Page_Maint_LCUBoardSet,pageinfo);
    connect(tcms_maint_lcuboard_switch_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));
    connect(tcms_maint_lcuboard_switch_,SIGNAL(signal_ForceLCU(int,bool)),this,SLOT(slot_ForceLCU(int,bool)));

    tcms_maint_clean_brake_ = new PageCleanBrake(this);
    tcms_maint_clean_brake_->move(TCMSPagePOS);
    tcms_maint_clean_brake_->hide();
    pageinfo = {tcms_maint_clean_brake_,"清洁制动"};
    map_pageindex_pageinfo_.insert(Page_Maint_CleanBrk,pageinfo);
    connect(tcms_maint_clean_brake_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));
    connect(tcms_maint_clean_brake_,SIGNAL(signal_CleanBrakeActive(bool)),this,SLOT(slot_CleanBrakeActive(bool)));

    tcms_maint_door_para_set_ = new PageDoorParameters(this);
    tcms_maint_door_para_set_->move(TCMSPagePOS);
    tcms_maint_door_para_set_->hide();
    pageinfo = {tcms_maint_door_para_set_,"门参数\n设置"};
    map_pageindex_pageinfo_.insert(Page_Maint_DorParSet,pageinfo);
    connect(tcms_maint_door_para_set_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));
    connect(tcms_maint_door_para_set_,SIGNAL(signal_DoorParam(uint8_t)),this,SLOT(slot_DoorParam(uint8_t)));

    tcms_maint_accumlations_ = new PageAccumlations(this);
    tcms_maint_accumlations_->move(TCMSPagePOS);
    tcms_maint_accumlations_->hide();
    pageinfo = {tcms_maint_accumlations_,"累计数据"};
    map_pageindex_pageinfo_.insert(Page_Maint_Accumulation,pageinfo);
    connect(tcms_maint_accumlations_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));
    connect(tcms_maint_accumlations_,SIGNAL(signal_TotalTimeSetValid(bool)),this,SLOT(slot_TotalTimeSetValid(bool)));
    connect(tcms_maint_accumlations_,SIGNAL(signal_TotalDisSetValid(bool)),this,SLOT(slot_TotalDisSetValid(bool)));
    connect(tcms_maint_accumlations_,SIGNAL(signal_AirComp1TimeSetValid(bool)),this,SLOT(slot_AirComp1TimeSetValid(bool)));
    connect(tcms_maint_accumlations_,SIGNAL(signal_AirComp6TimeSetValid(bool)),this,SLOT(slot_AirComp6TimeSetValid(bool)));
    connect(tcms_maint_accumlations_,SIGNAL(signal_ProEnergySetValid(bool)),this,SLOT(slot_ProEnergySetValid(bool)));
    connect(tcms_maint_accumlations_,SIGNAL(signal_AuxEnergySetValid(bool)),this,SLOT(slot_AuxEnergySetValid(bool)));

    tcms_maint_speed_test_ = new PageSpeedTest(this);
    tcms_maint_speed_test_->move(TCMSPagePOS);
    tcms_maint_speed_test_->hide();
    pageinfo = {tcms_maint_speed_test_,"加减速度\n测试"};
    map_pageindex_pageinfo_.insert(Page_Maint_SpeedTest,pageinfo);
    connect(tcms_maint_speed_test_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));
    connect(tcms_maint_speed_test_,SIGNAL(signal_speed_test_init(bool)),this,SLOT(slot_speed_test_init(bool)));
    connect(tcms_maint_speed_test_,SIGNAL(signal_speed_test_start(bool)),this,SLOT(slot_speed_test_start(bool)));

    tcms_maint_man_self_test_ = new PageMannualTest(this);
    tcms_maint_man_self_test_->move(TCMSPagePOS2);
    tcms_maint_man_self_test_->hide();
    pageinfo = {tcms_maint_man_self_test_,"自检测试"};
    map_pageindex_pageinfo_.insert(Page_Maint_ManualSelfTest,pageinfo);
    connect(tcms_maint_man_self_test_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));
    connect(tcms_maint_man_self_test_,SIGNAL(signal_BrkManTest(bool)),this,SLOT(slot_BrkManTest(bool)));

    tcms_maint_pis_breaker_test_ = new PagePISBreakerTest(this);
    tcms_maint_pis_breaker_test_->move(TCMSPagePOS);
    tcms_maint_pis_breaker_test_->hide();
    pageinfo = {tcms_maint_pis_breaker_test_,"PIS断路器\n测试"};
    map_pageindex_pageinfo_.insert(Page_Maint_PISBreakerTest,pageinfo);
    connect(tcms_maint_pis_breaker_test_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));
    connect(tcms_maint_pis_breaker_test_,SIGNAL(signal_ResetPISBreaker(bool)),this,SLOT(slot_ResetPISBreaker(bool)));
    connect(tcms_maint_pis_breaker_test_,SIGNAL(signal_OpenPISBreaker(uint8_t,bool)),this,SLOT(slot_OpenPISBreaker(uint8_t,bool)));

    tcms_maint_other_test_ = new PageOtherTests(this);
    tcms_maint_other_test_->move(TCMSPagePOS);
    tcms_maint_other_test_->hide();
    pageinfo = {tcms_maint_other_test_,"其它测试"};
    map_pageindex_pageinfo_.insert(Page_Maint_OtherTest,pageinfo);
    connect(tcms_maint_other_test_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));
    connect(tcms_maint_other_test_,SIGNAL(signal_AuxCompStart(bool)),this,SLOT(slot_AuxCompStart(bool)));
    connect(tcms_maint_other_test_,SIGNAL(signal_NSKCutOff(bool)),this,SLOT(slot_NSKCutOff(bool)));
    connect(tcms_maint_other_test_,SIGNAL(signal_SwitchToNet(bool)),this,SLOT(slot_SwitchToNet(bool)));
    connect(tcms_maint_other_test_,SIGNAL(signal_WheelTreadClean(bool)),this,SLOT(slot_WheelTreadClean(bool)));
    connect(tcms_maint_other_test_,SIGNAL(signal_EDBCut(uint8_t,bool)),this,SLOT(slot_EDBCut(uint8_t,bool)));
    connect(tcms_maint_other_test_,SIGNAL(signal_HSCB_Open(bool)),this,SLOT(slot_HSCB_Open(bool)));
    connect(tcms_maint_other_test_,SIGNAL(signal_HSCB_Close(bool)),this,SLOT(slot_HSCB_Close(bool)));

    tcms_maint_version_ = new PageVersion(this);
    tcms_maint_version_->move(TCMSPagePOS);
    tcms_maint_version_->hide();
    pageinfo = {tcms_maint_version_,"软件版本"};
    map_pageindex_pageinfo_.insert(Page_Maint_Version,pageinfo);
    connect(tcms_maint_version_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));

    tcms_maint_network_ = new PageMaintNetwork(this);
    tcms_maint_network_->move(TCMSPagePOS);
    tcms_maint_network_->hide();
    pageinfo = {tcms_maint_network_,"网络拓扑"};
    map_pageindex_pageinfo_.insert(Page_Maint_Network,pageinfo);
    connect(tcms_maint_network_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));

    tcms_maint_key_cbs_ = new PageKeyCBStat(this);
    tcms_maint_key_cbs_->move(TCMSPagePOS);
    tcms_maint_key_cbs_->hide();
    pageinfo = {tcms_maint_key_cbs_,"断路器\n状态"};
    map_pageindex_pageinfo_.insert(Page_Maint_KeyCBStat,pageinfo);
    connect(tcms_maint_key_cbs_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));
    connect(tcms_maint_key_cbs_,SIGNAL(signal_ResetCircuitBreak(bool)),this,SLOT(slot_ResetCircuitBreak(bool)));

    tcms_maint_switch_ = new PageSwitch(this);
    tcms_maint_switch_->move(TCMSPagePOS);
    tcms_maint_switch_->hide();
    pageinfo = {tcms_maint_switch_,"交换机\n状态"};
    map_pageindex_pageinfo_.insert(Page_Maint_Switch,pageinfo);
    connect(tcms_maint_switch_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));

    tcms_maint_battery_ = new PageMaintBattery(this);
    tcms_maint_battery_->move(TCMSPagePOS);
    tcms_maint_battery_->hide();
    pageinfo = {tcms_maint_battery_,"蓄电池\n状态"};
    map_pageindex_pageinfo_.insert(Page_Maint_Battery,pageinfo);
    connect(tcms_maint_battery_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));

    tcms_maint_io_ = new PageInterface(this);
    tcms_maint_io_->move(TCMSPagePOS);
    tcms_maint_io_->hide();
    pageinfo = {tcms_maint_io_,"接口检查"};
    map_pageindex_pageinfo_.insert(Page_Maint_Interface,pageinfo);
    connect(tcms_maint_io_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));

    tcms_maint_hardware_ = new PageHardWareStat(this);
    tcms_maint_hardware_->move(TCMSPagePOS);
    tcms_maint_hardware_->hide();
    pageinfo = {tcms_maint_hardware_,"设备状态"};
    map_pageindex_pageinfo_.insert(Page_Maint_Hardware,pageinfo);
    connect(tcms_maint_hardware_,SIGNAL(returnToMaintMenu()),this,SLOT(slot_Go_Back()));
    connect(tcms_maint_hardware_,SIGNAL(signal_manual_change_board(bool)),this,SLOT(slot_ManualChangeBoard(bool)));

    navigation_ = new Navigation(this);
    navigation_->move(NaviBarPOS);
    connect(navigation_,SIGNAL(signal_navibtn_index_tcms(int)),this,SLOT(slot_Show_Page(int)));
    connect(navigation_,SIGNAL(signal_navibtn_index_cctv(int)),this,SLOT(slot_Show_CCTV_Page(int)));
    connect(tcms_operation_,SIGNAL(signal_NextStationPA()),tcms_pis_station_set_,SLOT(slotNextStationPA()));
    connect(tcms_operation_,SIGNAL(signal_PreStationPA()),tcms_pis_station_set_,SLOT(slotPreStationPA()));
    connect(tcms_operation_,SIGNAL(signal_DepartPA(bool)),this,SLOT(slot_DepartPA(bool)));
    connect(tcms_operation_,SIGNAL(signal_ArrivedPA(bool)),this,SLOT(slot_ArrivedPA(bool)));

    GlobalConfig::addOperationInfo(QString("TCMS界面初始化完成"));
#ifdef TFS3536
    tfs_cctv_ = new TFS3536Main(this);
    tfs_cctv_->InitVideoNew(this,QRect(1220,100,700,900));
    tfs_cctv_->SetVideoShow();

    tfs_cctv_->InitPlayback(this,QRect(0,100,this->width(),900));
    tfs_cctv_->SetPlaybackHide();

    tfs_cctv_->InitMediaControl(this,QRect(0,100,this->width(),900));
    tfs_cctv_->SetMediaControlHide();
#else
    cctv_realtime_monitor_ = new PISMonitor(this);
    cctv_realtime_monitor_->move(CCTVPagePOS);
#endif

    tcms_comflt_page1_ = new QLabel(this);//cover titlebar
    tcms_comflt_page1_->setGeometry(0,100,1220,350);
    tcms_comflt_page1_->setStyleSheet("background-color:rgb(0,0,0);color:rgb(255,255,255);font:40pt 'Arial';border:none;");
    tcms_comflt_page1_->setText("通信检查中");
    tcms_comflt_page1_->setAlignment(Qt::AlignCenter);
    tcms_comflt_page1_->hide();

    tcms_comflt_page2_ = new QLabel(this);//cover navigationbar
    tcms_comflt_page2_->setGeometry(0,1000,1220,140);
    tcms_comflt_page2_->setStyleSheet("background-color:rgb(0,0,0);color:rgb(255,255,255);font:35pt 'Arial';border:none;");
    tcms_comflt_page2_->hide();

    tcms_comflt_page3_ = new QLabel(this);//cover titlbar
    tcms_comflt_page3_->setGeometry(0,0,1920,100);
    tcms_comflt_page3_->setStyleSheet("background-color:rgb(0,0,0);color:rgb(255,255,255);font:35pt 'Arial';border:none;");
    tcms_comflt_page3_->hide();

    tcms_comflt_page4_ = new QLabel(this);//cover side navi in operation page
    tcms_comflt_page4_->setGeometry(1100,450,120,490);
    tcms_comflt_page4_->setStyleSheet("background-color:rgb(0,0,0);color:rgb(255,255,255);font:35pt 'Arial';border:none;");
    tcms_comflt_page4_->hide();

    tcms_comflt_page5_ = new QLabel(this);//cover atc
    tcms_comflt_page5_->setGeometry(0,450,1220,490);
    tcms_comflt_page5_->setStyleSheet("background-color:rgb(0,0,0);color:rgb(255,255,255);font:35pt 'Arial';border:none;");
    tcms_comflt_page5_->hide();

    tcms_comflt_page6_ = new QLabel(this);//cover fault bar in operation page
    tcms_comflt_page6_->setGeometry(0,940,1220,60);
    tcms_comflt_page6_->setStyleSheet("background-color:rgb(0,0,0);color:rgb(255,255,255);font:35pt 'Arial';border:none;");
    tcms_comflt_page6_->hide();
    GlobalConfig::addOperationInfo(QString("CCTV界面初始化完成"));
}

void MainWindow::LocalTest()
{
#ifndef Q_OS_LINUX
    local_test_widget_ = new TestWidget();
    local_test_widget_->setWindowIcon(QIcon(":/res/logo22.png"));
    local_test_widget_->hide();
    connect(local_test_widget_,SIGNAL(valueChange(int,int,ulong)),this,SLOT(slotMapVar(int,int,ulong)));
#endif
}

void MainWindow::keyPressEvent(QKeyEvent *e)
{
    switch(e->key())
    {
    case Qt::Key_Escape:
        exit(0);
        break;
    case Qt::Key_F1:
        static bool xshow_tcms_comflt = false;
        if(!xshow_tcms_comflt)
            Show_TCMS_ComFlt();
        else
            Hide_TCMS_ComFlt();
        xshow_tcms_comflt = !xshow_tcms_comflt;
        break;
    case Qt::Key_F2:
        static bool xshow_atc_comflt = false;
        if(!xshow_atc_comflt)
            tcms_operation_->setATCComflt(true);
        else
            tcms_operation_->setATCComflt(false);
        xshow_atc_comflt = !xshow_atc_comflt;
        break;
    case Qt::Key_F3:
        local_test_widget_->show();
        break;
    case Qt::Key_F4:
        tcms_operation_->train()->setDisplayNormalStat();
        break;
    case Qt::Key_F5:
        tcms_operation_->train()->setDisplayUnNormalStat();
        break;
    case Qt::Key_F6:
        setPagesActive(true);
        setPisPageActive(true);
        break;
    }
}

void MainWindow::setPagesActive(bool xActive)
{
    tcms_hvac_->setPageActive(xActive);
    tcms_maint_time_set_->setPageActive(xActive);
    tcms_maint_accumlations_->setPageActive(xActive);
    tcms_maint_trainnum_set_->setPageActive(xActive);
    tcms_setting_reset_pce_siv_->setPageActive(xActive);
    tcms_maint_door_para_set_->setPageActive(xActive);
    tcms_maint_wheel_set_->setPageActive(xActive);
    tcms_maint_lcuboard_switch_->setPageActive(xActive);
    tcms_maint_clean_brake_->setPageActive(xActive);
    tcms_maint_speed_test_->setPageActive(xActive);
    tcms_maint_man_self_test_->setPageActive(xActive);
}

void MainWindow::setPisPageActive(bool xActive)
{
    tcms_pis_skip_station_set_->setPageActive(xActive);
    tcms_pis_mode_set_->setPageActive(xActive);
    tcms_pis_station_set_->setPageActive(xActive);
}

void MainWindow::slot_Show_EventHint()
{
    if(tcms_event_side_navi_->EventBtnId() == Page_Event_Cur)
        tcms_event_current_->showCurEventHint();
    else if(tcms_event_side_navi_->EventBtnId() == Page_Event_His)
        tcms_event_history_->showHisEventHint();
}

void MainWindow::slot_LoginSuccess()
{
    ChangeSubPage(cur_subpage_,Page_Maint_Menu);
}

void MainWindow::slot_Show_Page(int pageIndex)
{
    if(cur_subpage_ == pageIndex)
        return;
    ChangeSubPage(cur_subpage_,pageIndex);
}

void MainWindow::slot_Show_CCTV_Page(int pageIndex)
{
    if(cur_cctv_subpage_ == pageIndex)
        return;
    cur_cctv_subpage_ = pageIndex;
    if(pageIndex == Page_CCTV_RealTimeMonitor)
    {
#ifdef TFS3536
        tfs_cctv_->SetVideoShow();
        tfs_cctv_->SetPlaybackHide();
        tfs_cctv_->SetMediaControlHide();
#endif
        toptitle_->setTitleName(map_pageindex_pageinfo_.value(cur_subpage_).SubPageName);
        map_pageindex_pageinfo_.value(cur_subpage_).pSubPage->show();
        Show_NaviBarsAndMinitrain_When_CCTV_Hide(cur_subpage_);
        Show_TCMS_ComFlt_When_CCTV_Hide();
    }
    else if(pageIndex == Page_CCTV_PlayRecord)
    {
#ifdef TFS3536
        tfs_cctv_->SetVideoHide();
        tfs_cctv_->SetPlaybackShow();
        tfs_cctv_->SetMediaControlHide();
#endif
        toptitle_->setTitleName("录像回放");
        map_pageindex_pageinfo_.value(cur_subpage_).pSubPage->hide();
        Hide_NaviBarsAndMinitrain_When_CCTV_Show(cur_subpage_);
        Hide_TCMS_ComFlt_When_CCTV_Show();
    }
    else if(pageIndex == Page_CCTV_MedieaManage)
    {
#ifdef TFS3536
        tfs_cctv_->SetVideoHide();
        tfs_cctv_->SetPlaybackHide();
        tfs_cctv_->SetMediaControlShow();
#endif
        toptitle_->setTitleName("媒体管理");
        map_pageindex_pageinfo_.value(cur_subpage_).pSubPage->hide();
        Hide_NaviBarsAndMinitrain_When_CCTV_Show(cur_subpage_);
        Hide_TCMS_ComFlt_When_CCTV_Show();
    }
}

void MainWindow::slot_Go_Back()
{
    if(cur_subpage_ == old_subpage_)
        return;
    ChangeSubPage(cur_subpage_,old_subpage_);
}

void MainWindow::ChangeSubPage(int oldPage, int newPage)
{
//    qDebug()<<"change sub page--"<<"old page:"<<oldPage<<"new page:"<<newPage;
    if( !map_pageindex_pageinfo_.contains(oldPage) || !map_pageindex_pageinfo_.contains(newPage))
        return;
    map_pageindex_pageinfo_.value(oldPage).pSubPage->hide();
    map_pageindex_pageinfo_.value(newPage).pSubPage->show();
//---------------pis navi control-------------------
    if(newPage >= Page_PIS_ModeSetting && newPage <= Page_PIS_VolumeSetting)
        tcms_pis_side_navi_->show();
    else
        tcms_pis_side_navi_->hide();

    if(newPage == Page_PIS_ModeSetting)
        tcms_pis_side_navi_->ResetBtnCheckStat();
//---------------vehicle navi control---------------
    if(newPage >= Page_Vehcile_Traction && newPage <= Page_Vehcile_PECU)
    {
        tcms_vehicle_side_navi_->show();
//        tcms_vehicle_side_navi_->raise();
        tcms_vehicle_side_navi_->setBtnChecked(newPage);
        if(oldPage == Page_Operation)
            navigation_->setNaviBtnChecked(Page_Vehcile_Traction);
    }
    else
    {
        tcms_vehicle_side_navi_->hide();
    }
//---------------event navi control-------------------
    if(newPage >= Page_Event_Cur && newPage <= Page_Event_His)
    {
        tcms_event_side_navi_->show();
        tcms_event_history_->hideHintInfo();
        tcms_event_current_->hideHintInfo();
    }
    else
        tcms_event_side_navi_->hide();

    if(newPage == Page_Event_Cur)
        tcms_event_side_navi_->ResetBtnCheckStat();
//---------------setting navi control-------------------
    if(newPage >= Page_Setting_ResetPCESIV && newPage <= Page_Setting_BackLight)
        tcms_setting_side_navi_->show();
    else
        tcms_setting_side_navi_->hide();

    if(newPage == Page_Setting_ResetPCESIV)
        tcms_setting_side_navi_->ResetBtnCheckStat();
//---------------mini Train---------------
    if((newPage >= Page_Vehcile_Traction && newPage <= Page_Vehcile_PECU) || newPage == Page_Maint_ManualSelfTest
            || newPage == Page_HVAC)
        mini_train_->show();
    else
        mini_train_->hide();
//---------------------------------------------------
    cur_subpage_ = newPage;
    old_subpage_ = oldPage;
    toptitle_->setTitleName(map_pageindex_pageinfo_.value(newPage).SubPageName);
}
//--定时任务
void MainWindow::slot_CycleTask()
{
    static uint cycle_count = 0;
    bool tcms_comflt = false,atc_comflt = false;
    cycle_count++;
    cycle_count= cycle_count%20;
    if(cycle_count%2 == 0)//1s
    {
        SyncTCMSTime();
        tcms_comflt = CheckTCMSHeartBeats();
        atc_comflt = CheckATCHeartBeats();
        ChangeBoard(tcms_comflt || atc_comflt || manual_change_);
    }
    SendDDUHeartBeat();
    static bool last_period_is_master = false;
    bool this_period_is_master = CheckCurrentBoardIsMainBoard();
    if(!last_period_is_master && this_period_is_master)
        tcms_operation_->atc_page()->try_play_sound();
    last_period_is_master = this_period_is_master;
    tcms_operation_->atc_page()->flush_ATC_ComFlt_Info(GlobalConfig::ATPFS_Active,GlobalConfig::trainSpeed);
}

void MainWindow::ChangeBoard(bool should_change)
{
    static bool last_should_change = false;
    ddu_start_cnt++;
    if(ddu_start_cnt < 120)//刚开机的两分钟内不判断切换
        return;

    tcms_maint_hardware_->flush_hardware_stat();//两分钟之后再开始刷新板卡状态
//    static bool xflag = false;
//    if(should_change && !last_should_change && !xflag)
//    {
//        qDebug()<<"should change board..";
//        xflag = true;
//#ifdef RUN_IN_BOARD
//        avic_set_heart(false);
//#endif
//        QTimer::singleShot(5000,this,[=](){
//#ifdef RUN_IN_BOARD
//            avic_set_heart(true);
//#endif
//            xflag = false;
//        });
//    }
//    last_should_change = should_change;
    if(should_change && !last_should_change)
    {
#ifdef RUN_IN_BOARD
        avic_set_heart(false);
#endif
        GlobalConfig::addOperationInfo(QString("stop board heartbeats.."));
    }
    else if(!should_change && last_should_change)
    {
#ifdef RUN_IN_BOARD
        avic_set_heart(true);
#endif
        GlobalConfig::addOperationInfo(QString("set board heartbeats.."));
    }
    last_should_change = should_change;
}

bool MainWindow::CheckCurrentBoardIsMainBoard()
{
    bool is_master = false;
#ifdef RUN_IN_BOARD
    is_master = (avic_get_currentBoardId() == avic_get_mainBoardId());
    dataHandler->setSendVarValue(0,4,0,is_master);
    dataHandler->setSendVarValue(0,122,0,is_master);
#endif
    return is_master;
}

bool MainWindow::CheckTCMSHeartBeats()
{
    //check VCU heartbeat
#ifdef RUN_IN_BOARD
    static uint old_hb=0;
    uint hb = dataHandler->getRecvVarValueByOffset(0, 0, 0);
    if(old_hb != hb)
    {
        old_hb = hb;
        if(tcms_comflt_)
        {
            tcms_comflt_ = false;
            Hide_TCMS_ComFlt();
        }
    }
    else if(!tcms_comflt_)
    {
        tcms_comflt_ = true;
        qDebug() << "******** cannot receive vcu heartbreak ********";
        GlobalConfig::addOperationInfo(QString("cannot receive vcu heartbreak"));
        Show_TCMS_ComFlt();
    }
#endif
    return tcms_comflt_;
}

bool MainWindow::CheckATCHeartBeats()
{
#ifdef RUN_IN_BOARD
    static uint atc_old_hb=0;
    uint hb = dataHandler->getRecvVarValueByOffset(4, 84, 0);
    if(atc_old_hb != hb)
    {
        atc_old_hb = hb;
        if(atc_comflt_)
        {
            atc_comflt_ = false;
            tcms_operation_->setATCComflt(atc_comflt_ || GlobalConfig::ATPFS_Active);
        }
    }
    else if(!atc_comflt_)
    {
        atc_comflt_ = true;
        qDebug() << "******** cannot receive atc heartbreak ********";
        GlobalConfig::addOperationInfo(QString("cannot receive atc heartbreak"));
        tcms_operation_->setATCComflt(true);
    }
#endif
    return atc_comflt_;
}

void MainWindow::SendDDUHeartBeat()
{
    static uint ddu_heartbeats = 0;
    ddu_heartbeats++;
    if(ddu_heartbeats == 65535)
        ddu_heartbeats = 0;
#ifdef RUN_IN_BOARD
    dataHandler->setSendVarValue(0,0,0,ddu_heartbeats);
#endif
}

void MainWindow::SyncTCMSTime()
{
#ifdef RUN_IN_BOARD
    toptitle_->setDateTime();
    uint t = dataHandler->getTime();
    if(t!=0xffffffff && !tcms_comflt_)
        setSystemTime(t);
#endif
}

void MainWindow::setSystemTime(uint t)
{
#ifdef RUN_IN_BOARD
    struct timeval val;
    int ret_get_time = gettimeofday(&val, NULL);
    if (ret_get_time == -1)
    {
        printf("Error: gettimeofday()\n");
        return;
    }

    if(abs(val.tv_sec-t) > 5)
    {
        struct timeval new_val = {(long)t,0};
        settimeofday(&new_val,NULL);
        if(has_not_sync_time_ever_)
        {
            QString cmd = QString("/home/hi_test/rtc_test -s time %1").arg(QDateTime::fromTime_t(t).toString("yyyy/MM/dd/H/m/s"));
            system(cmd.toLatin1().data());
            has_not_sync_time_ever_ = false;
        }
        qDebug() << "set system time............" << val.tv_sec << "->" << t << ":" << QDateTime::fromTime_t(t).toString("yyyy-MM-dd hh:mm:ss");
        GlobalConfig::addOperationInfo(QString("校时:%1 --> %2").arg(val.tv_sec).arg(t));
    }
#endif
}

void MainWindow::Show_TCMS_ComFlt()
{
    tcms_comflt_page1_->show();
    tcms_comflt_page2_->show();
    tcms_comflt_page3_->show();
    tcms_comflt_page4_->show();
    tcms_comflt_page5_->setVisible(cur_subpage_ != Page_Operation);
    tcms_comflt_page6_->show();
}

void MainWindow::Hide_TCMS_ComFlt()
{
    tcms_comflt_page1_->hide();
    tcms_comflt_page2_->hide();
    tcms_comflt_page3_->hide();
    tcms_comflt_page4_->hide();
    tcms_comflt_page5_->hide();
    tcms_comflt_page6_->hide();
}

void MainWindow::Hide_TCMS_ComFlt_When_CCTV_Show()
{
    tcms_comflt_page1_->hide();
    tcms_comflt_page4_->hide();
    tcms_comflt_page5_->hide();
    tcms_comflt_page6_->hide();
}

void MainWindow::Show_TCMS_ComFlt_When_CCTV_Hide()
{
    tcms_comflt_page1_->setVisible(tcms_comflt_);
    tcms_comflt_page4_->setVisible(tcms_comflt_);
    tcms_comflt_page6_->setVisible(tcms_comflt_);
    tcms_comflt_page5_->setVisible(tcms_comflt_ && cur_subpage_ != Page_Operation);
}

void MainWindow::Show_NaviBarsAndMinitrain_When_CCTV_Hide(int page)
{
//---------------pis navi-------------------
    if(page >= Page_PIS_ModeSetting && page <= Page_PIS_VolumeSetting)
        tcms_pis_side_navi_->show();
//---------------vehicle navi---------------
    else if(page >= Page_Vehcile_Traction && page <= Page_Vehcile_PECU)
        tcms_vehicle_side_navi_->show();
//---------------event navi-------------------
    else if(page >= Page_Event_Cur && page <= Page_Event_His)
        tcms_event_side_navi_->show();
//---------------setting navi-------------------
    else if(page >= Page_Setting_ResetPCESIV && page <= Page_Setting_BackLight)
        tcms_setting_side_navi_->show();
//---------------mini Train---------------
    if((page >= Page_Vehcile_Traction && page <= Page_Vehcile_PECU) || page == Page_Maint_ManualSelfTest
            || page == Page_HVAC)
        mini_train_->show();
}

void MainWindow::Hide_NaviBarsAndMinitrain_When_CCTV_Show(int page)
{
//---------------pis navi-------------------
    if(page >= Page_PIS_ModeSetting && page <= Page_PIS_VolumeSetting)
        tcms_pis_side_navi_->hide();
//---------------vehicle navi---------------
    else if(page >= Page_Vehcile_Traction && page <= Page_Vehcile_PECU)
        tcms_vehicle_side_navi_->hide();
//---------------event navi-------------------
    else if(page >= Page_Event_Cur && page <= Page_Event_His)
        tcms_event_side_navi_->hide();
//---------------setting navi-------------------
    else if(page >= Page_Setting_ResetPCESIV && page <= Page_Setting_BackLight)
        tcms_setting_side_navi_->hide();
//---------------mini Train---------------
    if((page >= Page_Vehcile_Traction && page <= Page_Vehcile_PECU) || page == Page_Maint_ManualSelfTest
            || page == Page_HVAC)
        mini_train_->hide();
}

//通讯
void MainWindow::startCom()
{
#ifdef RUN_IN_BOARD
    dataHandler->initCom();
    dataHandler->startCom();
    usleep(5*1000*1000);
    if(dataHandler->getComState() != TRDPThread::running)
    {
        printf("start trdp com failed\n");
    }
    else
    {
        qDebug() << "init sending data start";
        sendDDUSWVer();
        sendVarValue(0,11,0,25); //初始给VCU发全车设置默认温度25℃
        qDebug() << "init sending data finish";

        usleep(100*1000);
        connect(dataHandler, SIGNAL(signalVarChanged(int,int,ulong)), SLOT(slotMapVar(int,int,ulong)));
        dataHandler->startParser();
    }
#endif
    GlobalConfig::addOperationInfo(QString("通信初始化完成，主线程%1").arg(getpid()));
}

//------Send Var via TRDP------
void MainWindow::sendVarValue(int comidIndex,int byte,int bit,int value)
{
    qDebug()<<"send comidIndex="<<comidIndex<<"byte="<<byte<<"bit="<<bit<<"value="<<value;
#ifdef RUN_IN_BOARD
    dataHandler->setSendVarValue(comidIndex,byte,bit,value);
#endif
}
//PIS
void MainWindow::slot_change_direction(uint8_t dir)
{
    if(dir == 1)
    {
        sendVarValue(0,89,0,1);
        sendVarValue(0,89,1,0);
    }
    else if(dir == 2)
    {
        sendVarValue(0,89,0,0);
        sendVarValue(0,89,1,1);
    }
}

void MainWindow::slot_set_pis_mode(int mode, bool xSet)
{
    sendVarValue(0,89,2,xSet);

    if(mode == PIS_ModeAuto)
    {
        sendVarValue(0,88,5,1);
        sendVarValue(0,88,6,0);
        sendVarValue(0,88,7,0);
    }
    else if(mode  == PIS_ModeMannual)
    {
        sendVarValue(0,88,5,0);
        sendVarValue(0,88,6,0);
        sendVarValue(0,88,7,1);
    }
    else if(mode == PIS_ModeSemiAuto)
    {
        sendVarValue(0,88,5,0);
        sendVarValue(0,88,6,1);
        sendVarValue(0,88,7,0);
    }
}

void MainWindow::slot_PisStationSet(bool xSet)
{
    sendVarValue(0,89,3,xSet);
    if(xSet)
    {
        sendVarValue(0,94,0,tcms_pis_station_set_->getStartStationID());
        sendVarValue(0,92,0,tcms_pis_station_set_->getEndStationID());
        sendVarValue(0,96,0,tcms_pis_station_set_->getCurrentStationID());
    }
}

void MainWindow::slot_DepartComfirm(bool xConfirm)
{
    sendVarValue(0,88,2,xConfirm);
}

void MainWindow::slot_EmBroadCastOnceValid(bool xValid)
{
    sendVarValue(0,88,0,xValid);
    if(xValid)
    {
        uint16_t em_broadcast_id = tcms_pis_em_broadcast_set_->getEmBroadCastID();
        sendVarValue(0,86,0,em_broadcast_id);
    }
}

void MainWindow::slot_EmBroadCastLoopValid(bool xValid)
{
    sendVarValue(0,88,1,xValid);
    if(xValid)
    {
        uint16_t em_broadcast_id = tcms_pis_em_broadcast_set_->getEmBroadCastID();
        sendVarValue(0,86,0,em_broadcast_id);
    }
}

void MainWindow::slot_SkipStationActive(bool xActive)
{
    sendVarValue(0,89,4,xActive);
}

void MainWindow::slot_SkipStationID(uint32_t id)
{
    sendVarValue(0,128,0,id);
}

void MainWindow::slot_DepartPA(bool xTrig)
{
    sendVarValue(0,88,3,xTrig);
}

void MainWindow::slot_ArrivedPA(bool xTrig)
{
    sendVarValue(0,88,4,xTrig);
}

//加减速度测试
void MainWindow::slot_speed_test_init(bool xInit)
{
    sendVarValue(0,111,3,xInit);
}

void MainWindow::slot_speed_test_start(bool xStart)
{
    sendVarValue(0,111,4,xStart);
    if(xStart)
    {
        uint8_t value = tcms_maint_speed_test_->getTestSpeed();
        sendVarValue(0,120,0,value);
    }
}

void MainWindow::slot_atc_test(uint8_t value)
{
    sendVarValue(0,121,0,value);
    QTimer::singleShot(500,this,[=](){
        sendVarValue(0,121,0,0);
    });
}

void MainWindow::slot_ResetCircuitBreak(bool xTrig)
{
    sendVarValue(0,109,7,xTrig);
}

void MainWindow::slot_ResetFireAlarm(bool xReset)
{
    sendVarValue(0,23,1,xReset);
}

void MainWindow::slot_TimeSet(bool xValid)
{
    sendVarValue(0,22,0,xValid);
    if(xValid)
    {
        uint8_t value = tcms_maint_time_set_->getSetYear() - 2000;
        sendVarValue(0,5,0,value);

        value = tcms_maint_time_set_->getSetMonth();
        sendVarValue(0,6,0,value);

        value = tcms_maint_time_set_->getSetDay();
        sendVarValue(0,7,0,value);

        value = tcms_maint_time_set_->getSetHour();
        sendVarValue(0,8,0,value);

        value = tcms_maint_time_set_->getSetMin();
        sendVarValue(0,9,0,value);

        value = tcms_maint_time_set_->getSetSecond();
        sendVarValue(0,10,0,value);
    }
}

//void MainWindow::slot_DayDisSetValid(bool xValid)
//{
////    sendVarValue(0,22,1,xValid);
////    if(xValid)
////    {
////        uint value = tcms_maint_accumlations_->getTotalRunDisInput();
////        sendVarValue(0,12,0,value);
////    }
//}

void MainWindow::slot_TotalDisSetValid(bool xValid)
{
    sendVarValue(0,22,1,xValid);
    if(xValid)
    {
        uint value = tcms_maint_accumlations_->getTotalRunDisInput();
        sendVarValue(0,12,0,value);
    }
}

void MainWindow::slot_TotalTimeSetValid(bool xValid)
{
    sendVarValue(0,22,2,xValid);
    if(xValid)
    {
        uint value = tcms_maint_accumlations_->getTotalRunTimeInput();
        sendVarValue(0,16,0,value);
    }
}

void MainWindow::slot_AirComp1TimeSetValid(bool xValid)
{
    sendVarValue(0,111,1,xValid);
    if(xValid)
    {
        uint value = tcms_maint_accumlations_->getAirCompTimeInput(0);
        sendVarValue(0,112,0,value);
    }
}

void MainWindow::slot_AirComp6TimeSetValid(bool xValid)
{
    sendVarValue(0,111,2,xValid);
    if(xValid)
    {
        uint value = tcms_maint_accumlations_->getAirCompTimeInput(1);
        sendVarValue(0,116,0,value);
    }
}

void MainWindow::slot_ProEnergySetValid(bool xValid)
{
    sendVarValue(0,31,6,xValid);
    if(xValid)
    {
        uint value = tcms_maint_accumlations_->getProEnergyInput();
        sendVarValue(0,36,0,value);
        value = tcms_maint_accumlations_->getRegEnergyInput();
        sendVarValue(0,40,0,value);
        value = tcms_maint_accumlations_->getBrkResEnergyInput();
        sendVarValue(0,124,0,value);
    }
}

void MainWindow::slot_AuxEnergySetValid(bool xValid)
{
    sendVarValue(0,31,7,xValid);
    if(xValid)
    {
        uint value = tcms_maint_accumlations_->getAuxEnergyInput();
        sendVarValue(0,44,0,value);
    }
}

void MainWindow::slot_LineSet(bool xValid)
{
    sendVarValue(0,22,3,xValid);
    if(xValid)
    {
        uint16_t value = tcms_maint_trainnum_set_->getLineIDInput();
        sendVarValue(0,21,0,value);
    }
}

void MainWindow::slot_TrainIDSet(bool xValid)
{
    sendVarValue(0,22,4,xValid);
    if(xValid)
    {
        uint16_t value = tcms_maint_trainnum_set_->getTrainIDInput();
        sendVarValue(0,20,0,value);
    }
}

void MainWindow::slot_ResetPCE(bool xReset)
{
    sendVarValue(0,23,7,xReset);
}

void MainWindow::slot_ResetACE(bool xReset)
{
    sendVarValue(0,23,6,xReset);
}

void MainWindow::slot_DoorParam(uint8_t value)
{
    sendVarValue(0,84,0,value);
    if(value == 0xAA)
    {
        sendVarValue(0,56,0,tcms_maint_door_para_set_->getDelOpen());
        sendVarValue(0,58,0,tcms_maint_door_para_set_->getDelClose());
        sendVarValue(0,60,0,tcms_maint_door_para_set_->getOpenTime());
        sendVarValue(0,62,0,tcms_maint_door_para_set_->getCloseTime());
        sendVarValue(0,64,0,tcms_maint_door_para_set_->getObstNumb());
        sendVarValue(0,66,0,tcms_maint_door_para_set_->getOpenWidthObst());
        sendVarValue(0,68,0,tcms_maint_door_para_set_->getSusTimObst());
        sendVarValue(0,70,0,tcms_maint_door_para_set_->getFinOpenWidthObst());
        sendVarValue(0,72,0,tcms_maint_door_para_set_->getAppTimObst());
        sendVarValue(0,74,0,tcms_maint_door_para_set_->getTightClose(0));
        sendVarValue(0,76,0,tcms_maint_door_para_set_->getTightClose(1));
        sendVarValue(0,78,0,tcms_maint_door_para_set_->getTightClose(2));
        sendVarValue(0,80,0,tcms_maint_door_para_set_->getTightClose(3));
        sendVarValue(0,82,0,tcms_maint_door_para_set_->getTightClose(4));
    }
}

void MainWindow::slot_OpenPISBreaker(uint8_t index,bool xOpen)
{
    sendVarValue(0,110,index,xOpen);
}

void MainWindow::slot_ResetPISBreaker(bool xReset)
{
    sendVarValue(0,109,7,xReset);
}

void MainWindow::slot_AuxCompStart(bool xStart)
{
    sendVarValue(0,23,0,xStart);
}

void MainWindow::slot_SwitchToNet(bool xChange)
{
    sendVarValue(0,100,0,xChange);
}

void MainWindow::slot_NSKCutOff(bool xCutoff)
{
    sendVarValue(0,23,5,xCutoff);
}

void MainWindow::slot_WheelTreadClean(bool xStart)
{
    sendVarValue(0,122,1,xStart);
}

void MainWindow::slot_EDBCut(uint8_t index, bool xCut)
{
    sendVarValue(0,30,2+index,xCut);
}

void MainWindow::slot_HSCB_Open(bool xOpen)
{
    sendVarValue(0,30,6,xOpen);
}

void MainWindow::slot_HSCB_Close(bool xClose)
{
    sendVarValue(0,30,7,xClose);
}

void MainWindow::slot_ProWheelSetValid(bool xValid)
{
    sendVarValue(0,30,0,xValid);
    if(xValid)
    {
        uint8_t value = tcms_maint_wheel_set_->getProWheelInputValue(0);
        sendVarValue(0,24,0,value);

        value = tcms_maint_wheel_set_->getProWheelInputValue(1);
        sendVarValue(0,25,0,value);

        value = tcms_maint_wheel_set_->getProWheelInputValue(2);
        sendVarValue(0,26,0,value);

        value = tcms_maint_wheel_set_->getProWheelInputValue(3);
        sendVarValue(0,27,0,value);
    }
}

void MainWindow::slot_BrkWheelSetValid(bool xValid)
{
    sendVarValue(0,30,1,xValid);
    if(xValid)
    {
        uint16_t value = tcms_maint_wheel_set_->getBrkWheelInputValue(0);
        sendVarValue(0,28,0,value);

        value = tcms_maint_wheel_set_->getBrkWheelInputValue(1);
        sendVarValue(0,29,0,value);
    }
}

void MainWindow::slot_SendHvacMode(int mode, bool xValid)
{
    if(!xValid)
    {
        sendVarValue(0,48,0,0);
        sendVarValue(0,48,1,0);
        sendVarValue(0,48,2,0);
        sendVarValue(0,48,3,0);
        sendVarValue(0,48,4,0);
        return;
    }

    if(mode == HVAC_Vent)
        sendVarValue(0,48,0,1);
    else if(mode == HVAC_Auto)
        sendVarValue(0,48,1,1);
    else if(mode == HVAC_Man)
        sendVarValue(0,48,2,1);
    else if(mode == HVAC_Stop)
        sendVarValue(0,48,3,1);
    else if(mode == HVAC_OnlyTC)
        sendVarValue(0,48,4,1);
}

void MainWindow::slot_HvacTemp(int index,int temp)
{
    if(index == 0)
        sendVarValue(0,11,0,temp);
    else
        sendVarValue(0,48+index,0,temp);
}

void MainWindow::slot_OpenNADamper(bool xOpen)
{
    sendVarValue(0,48,6,xOpen);
}

void MainWindow::slot_CloseNADamper(bool xClose)
{
    sendVarValue(0,48,5,xClose);
}

void MainWindow::slot_ForceLCU(int index,bool xForce)
{
    if(xForce)
    {
        if(index == 0)
        {
            sendVarValue(0,23,3,1);
            sendVarValue(0,23,4,0);
        }
        else if(index == 1)
        {
            sendVarValue(0,23,3,0);
            sendVarValue(0,23,4,1);
        }
        else if(index == 2)
        {
            sendVarValue(0,23,3,0);
            sendVarValue(0,23,4,0);
        }
    }
}

void MainWindow::slot_BrkManTest(bool xTest)
{
    sendVarValue(0,111,0,xTest);
}

void MainWindow::slot_CleanBrakeActive(bool xActive)
{
    sendVarValue(0,111,5,xActive);
}

void MainWindow::slot_SetBackLight(int val)
{
#ifdef RUN_IN_BOARD
    if(hwDriver != NULL)
        hwDriver->setBrightness(val);
#endif
}

void MainWindow::mapToEvent(int comidIndex, int varoffset, unsigned long value)
{
    unsigned char size = 0;
    int index = GlobalConfig::getRecvVarIndex(comidIndex,varoffset);
    if(index != -1)
        size = GlobalConfig::recvTRDPList.at(comidIndex).node.at(index).size;
    uint id = (comidIndex+1)*10000 + varoffset;
    if(size == 1)
    {
        if(value)
            activeEvent(id);
        else
            clearEvent(id);
    }
    static int current_highest_fault_level = 0;
    if(current_highest_fault_level != GlobalConfig::getHighestFaultLevel())
        current_highest_fault_level = GlobalConfig::getHighestFaultLevel();
    else
        return;
    toptitle_->updateHighestLevelStat(current_highest_fault_level);
}

void MainWindow::activeEvent(uint id, unsigned long value)
{
    if(GlobalConfig::addEvent(id, value) == 0)
    {
        EventData data;
        int index = GlobalConfig::eventData.size()-1;
        tcms_event_current_->updateEvent();
        if(GlobalConfig::getEventData(index, data) == 0)
        {
            if(data.event.level=="1" || data.event.level=="2" || data.event.level=="4")
            {
                tcms_operation_->activateAlarm(id, data.startTime,data.event.car, data.event.description,data.event.level);
            }
        }
        beep();
    }
}

void MainWindow::clearEvent(uint id)
{
    GlobalConfig::removeEvent(id);
    if(!GlobalConfig::eventData.isEmpty())
    {
        //导航键显示红 待修改
    }
    tcms_event_current_->updateEvent();
    tcms_event_history_->updateHistory();
}

void MainWindow::mapToInterface(int comidIndex, int varoffset, unsigned long value)
{
    int byte = varoffset/10;
    unsigned char bit = varoffset%10;
    int id = (comidIndex+1)*10000 + byte*10 + bit;
    tcms_maint_io_->updateTableValue(id,value);
}

void MainWindow::beep(bool continuously)
{
#ifdef RUN_IN_BOARD
    if(hwDriver != NULL)
        hwDriver->startBeep(continuously);
#else
    Q_UNUSED(continuously);
#endif
}

void MainWindow::stopbeep()
{
#ifdef RUN_IN_BOARD
    if(hwDriver != NULL)
        hwDriver->stopBeep();
#endif
}

void MainWindow::setBeepEnable(bool xEnable)
{
#ifdef RUN_IN_BOARD
    if(hwDriver != NULL)
        hwDriver->setBeepEnable(xEnable);
#endif
}

inline int MainWindow::indexOfoffset(int varoffset)
{
    return (varoffset/10)*8 + varoffset%10;
}

void MainWindow::slotMapVar(int comidIndex, int varoffset, unsigned long value)
{
    if(ddu_start_cnt <300 && comidIndex<5 && !(comidIndex==0 && varoffset<80))
        GlobalConfig::writeLog(QString("comidIndex:%1,varoffset:%2,value:%3").arg(comidIndex).arg(varoffset).arg(value));

    switch (comidIndex) {
    case 0:
        if(varoffset == 4815 || varoffset == 4816 || varoffset == 4817 || varoffset == 4820)
        {
#ifdef RUN_IN_BOARD
            tcms_operation_->train()->setEffDmd(dataHandler->getRecvVarValueByOffset(comidIndex,481,5),
                                       dataHandler->getRecvVarValueByOffset(comidIndex,481,6),
                                       dataHandler->getRecvVarValueByOffset(comidIndex,481,7),
                                       dataHandler->getRecvVarValueByOffset(comidIndex,482,0));
#else
            tcms_operation_->train()->setEffDmd(true,false,true,value);
#endif
            if(varoffset == 4820)
                toptitle_->setEffDmd(value);
        }
        break;
    case 1:
        if(varoffset >= 0 && varoffset <= 10)
            tcms_operation_->train()->setPanStat(varoffset/10,value);
        else if(varoffset >= 30 && varoffset <= 40)
            tcms_bypass_->setBypassStat(PageBypass::ByPASS_PEBPS,(varoffset-30)/10,value);
        else if(varoffset >= 50 && varoffset <= 90)
            tcms_fire_stat_->setSHDStat(0,(varoffset-50)/10,value);
        else if(varoffset >= 100 && varoffset <= 130)
            tcms_fire_stat_->setSHDStat(1,(varoffset-100)/10,value);
        else if(varoffset >= 140 && varoffset <= 170)
            tcms_fire_stat_->setSHDStat(2,(varoffset-140)/10,value);
        else if(varoffset >= 180 && varoffset <= 210)
            tcms_fire_stat_->setSHDStat(3,(varoffset-180)/10,value);
        else if(varoffset >= 220 && varoffset <= 250)
            tcms_fire_stat_->setSHDStat(4,(varoffset-220)/10,value);
        else if(varoffset >= 260 && varoffset <= 300)
            tcms_fire_stat_->setSHDStat(5,(varoffset-260)/10,value);
        else if(varoffset >= 310 && varoffset <= 340)
            tcms_fire_stat_->setLHDStat(0,(varoffset-310)/10,value);
        else if(varoffset >= 350 && varoffset <= 370)
            tcms_fire_stat_->setLHDStat(1,(varoffset-350)/10,value);
        else if(varoffset >= 380 && varoffset <= 400)
            tcms_fire_stat_->setLHDStat(2,(varoffset-380)/10,value);
        else if(varoffset >= 410 && varoffset <= 430)
            tcms_fire_stat_->setLHDStat(3,(varoffset-410)/10,value);
        else if(varoffset >= 440 && varoffset <= 460)
            tcms_fire_stat_->setLHDStat(4,(varoffset-440)/10,value);
        else if(varoffset >= 470 && varoffset <= 510)
            tcms_fire_stat_->setLHDStat(5,(varoffset-470)/10,value);
        else if(varoffset == 520 )
            tcms_maint_version_->setDevVersion(PageVersion::Ver_FCU,1,value,16,"4.4.8");
        else if(varoffset == 540)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_FCU,6,value,16,"4.4.8");
        else if(varoffset == 560)
            tcms_maint_accumlations_->setTotalEnergyConsume(value);
        else if(varoffset == 680 )
            tcms_maint_version_->setDevVersion(PageVersion::Ver_ECR,2,value,16,"4.4.8");
        else if(varoffset == 700)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_ECR,5,value,16,"4.4.8");
        else if(varoffset == 760)
            tcms_aux_stat_->setAuxStat(7,0,value);
        else if(varoffset == 770)
            tcms_aux_stat_->setAuxStat(7,2,value);
        else if(varoffset == 780)
            tcms_aux_stat_->setAuxStat(7,3,value);
        else if(varoffset == 790)
            tcms_aux_stat_->setAuxStat(7,5,value);
        else if(varoffset >= 800 && varoffset <= 830)
            tcms_operation_->train()->setAuxConvertStat((varoffset-800)/10,value);
        else if(varoffset == 840)
            toptitle_->setHighVoltage(value);
        else if(varoffset == 860)
            tcms_aux_stat_->setAuxStat(0,0,value);
        else if(varoffset == 880)
            tcms_aux_stat_->setAuxStat(0,2,value);
        else if(varoffset == 900)
            tcms_aux_stat_->setAuxStat(0,3,value);
        else if(varoffset == 920)
            tcms_aux_stat_->setAuxStat(0,5,value);
        else if(varoffset == 940)
            tcms_aux_stat_->setAuxStat(1,0,value);
        else if(varoffset == 960)
            tcms_aux_stat_->setAuxStat(1,2,value);
        else if(varoffset == 980)
            tcms_aux_stat_->setAuxStat(1,3,value);
        else if(varoffset == 1000)
            tcms_aux_stat_->setAuxStat(1,5,value);
        else if(varoffset == 1020)
            tcms_aux_stat_->setAuxStat(9,0,value);
        else if(varoffset == 1030)
            tcms_aux_stat_->setAuxStat(9,2,value);
        else if(varoffset == 1040)
            tcms_aux_stat_->setAuxStat(9,3,value);
        else if(varoffset == 1050)
            tcms_aux_stat_->setAuxStat(9,5,value);
        else if(varoffset == 1060)
            tcms_aux_stat_->setAuxStat(8,0,value);
        else if(varoffset == 1070)
            tcms_aux_stat_->setAuxStat(8,5,value);
        else if(varoffset == 1120)
            tcms_aux_stat_->setAuxStat(2,0,value);
        else if(varoffset == 1140)
            tcms_aux_stat_->setAuxStat(2,2,value);
        else if(varoffset == 1160)
            tcms_aux_stat_->setAuxStat(2,3,value);
        else if(varoffset == 1180)
            tcms_aux_stat_->setAuxStat(2,5,value);
        else if(varoffset == 1200)
            tcms_aux_stat_->setAuxStat(3,0,value);
        else if(varoffset == 1220)
            tcms_aux_stat_->setAuxStat(3,5,value);
        else if(varoffset == 1240)
            tcms_maint_accumlations_->setAuxEnergyConsume(value);
        else if(varoffset >= 1280 && varoffset <= 1290)
            tcms_operation_->train()->setTSKStat((varoffset-1280)/10,value);
        else if(varoffset >= 1300 && varoffset <= 1330)
            tcms_operation_->train()->setBatChargerStat((varoffset-1300)/10,value);
        else if(varoffset >= 1340 && varoffset <= 1350)
            tcms_bypass_->setBypassStat(PageBypass::BYPASS_BIS,(varoffset-1340)/10,value);
        else if(varoffset >= 1360 && varoffset <= 1370)
            tcms_operation_->train()->setIESStat((varoffset-1360)/10,value);
        else if(varoffset == 1380)
            tcms_aux_stat_->setAuxStat(4,2,value);
        else if(varoffset == 1720)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_TCDS,1,value,16,"4.4.8");
        else if(varoffset >= 1740 && varoffset <= 1840)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_LCUCOM,(varoffset-1720)/20,value,16,"4.4.8");
        else if(varoffset >= 1860 && varoffset <= 1960)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_LCUCTL,(varoffset-1840)/20,value,16,"4.4.8");
        else if(varoffset >= 1980 && varoffset <= 2010)
            tcms_operation_->train()->setTracConvertStat((varoffset-1980)/10,value);
        else if(varoffset == 2040)
            tcms_maint_accumlations_->setProEnergyConsume(value);
        else if(varoffset == 2080)
            tcms_maint_accumlations_->setRegEnergyConsume(value);
        else if(varoffset == 2120)
            tcms_maint_accumlations_->setBrkResEnergyConsume(value);
        else if(varoffset >= 2160 && varoffset <= 2220)
            tcms_traction_stat_->setTracStat(0,(varoffset-2140)/20,value);
        else if(varoffset >= 2240 && varoffset <= 2300)
            tcms_traction_stat_->setTracStat(1,(varoffset-2220)/20,value);
        else if(varoffset >= 2320 && varoffset <= 2350)
            tcms_traction_stat_->setTracStat(2,(varoffset-2310)/10,value);
        else if(varoffset >= 2360 && varoffset <= 2420)
            tcms_traction_stat_->setTracStat(3,(varoffset-2340)/20,value);
        else if(varoffset >= 2440 && varoffset <= 2500)
            tcms_traction_stat_->setTracStat(4,(varoffset-2420)/20,value);
        else if(varoffset >= 2520 && varoffset <= 2550)
        {
            tcms_operation_->train()->setHSCBStat((varoffset-2520)/10,value);
            tcms_maint_other_test_->setHSCBStat((varoffset-2520)/10,value);
        }
        else if(varoffset >= 2560 && varoffset <= 2620)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_PCE,(varoffset-2520)/20,value,16,"4.4.8");
        else if(varoffset >= 2640 && varoffset <= 2670)
            tcms_traction_stat_->setTracStat(5,(varoffset-2630)/10,value);
        else if(varoffset >= 2700 && varoffset <= 2710)
        {
            GlobalConfig::ATPFSStat[(varoffset-2700)/10] = value;
            if(GlobalConfig::cabNumber==1)
                GlobalConfig::ATPFS_Active = GlobalConfig::ATPFSStat[0] == 1;
            else if(GlobalConfig::cabNumber==6)
                GlobalConfig::ATPFS_Active = GlobalConfig::ATPFSStat[1] == 1;
            tcms_bypass_->setBypassStat(PageBypass::ByPASS_ATPFS,(varoffset-2700)/10,value);
            tcms_operation_->atc_page()->Set_ATC_ComFlt_Page(atc_comflt_ || GlobalConfig::ATPFS_Active);
        }
        else if(varoffset == 2720)
        {
            tcms_operation_->train()->setTrainID(value);
            tcms_maint_network_->setTCDSVisible(Network_BlueAndRed,value == 7);
            tcms_maint_network_->setTCDSVisible(Network_Red,value == 7);
            tcms_maint_network_->setTCDSVisible(Network_Blue,value == 7);
            tcms_maint_trainnum_set_->setTrainID(value);
            tcms_self_test_->setTCDSVisible(value == 7);
            setLocalDeviceIP_eth1(value);
            tcms_maint_hardware_->flush_interface_info();
            tcms_maint_switch_->updateSwitchPortName(value);
        }
        else if(varoffset == 2730)
        {
            tcms_operation_->train()->setLineID(value);
            tcms_maint_trainnum_set_->setLineID(value);
        }
        else if(varoffset == 2760)
            tcms_maint_accumlations_->setTotalRunTime(value);
        else if(varoffset == 2800)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_DDUL,1,value,16,"4.4.8");
        else if(varoffset == 2820)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_DDUL,6,value,16,"4.4.8");
        else if(varoffset == 2840)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_VCU,1,value,16,"4.4.8");
        else if(varoffset == 2860)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_VCU,6,value,16,"4.4.8");
        else if(varoffset == 2880)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_VSCU,1,value,16,"4.4.8");
        else if(varoffset == 2900)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_VSCU,6,value,16,"4.4.8");
        else if(varoffset == 2920)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_EVR,4,value,16,"4.4.8");
        else if(varoffset == 2940)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_RIOM10,1,value,16,"4.4.8");
        else if(varoffset == 2960)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_RIOM10,6,value,16,"4.4.8");
        else if(varoffset >= 2980 && varoffset <= 3080)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_CS1,(varoffset-2960)/20,value,16,"4.4.8");
        else if(varoffset >= 3100 && varoffset <= 3200)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_CS2,(varoffset-3080)/20,value,16,"4.4.8");
        else if(varoffset == 3220)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_EVR,1,value,16,"4.4.8");
        else if(varoffset == 3240)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_EVR,6,value,16,"4.4.8");
        else if(varoffset >= 3280 && varoffset <= 3720)
            tcms_maint_switch_->setSwitchPortStat(((varoffset-3280)/40)%6,(varoffset-3280)/240,
                                                  value,
#ifdef RUN_IN_BOARD
                                                  dataHandler->getRecvVarValueByOffset(comidIndex,376+(varoffset-3280)/10,0));
#else
                                                  0);
#endif
        else if(varoffset >= 3760 && varoffset <= 4200)
            tcms_maint_switch_->setSwitchPortStat(((varoffset-3760)/40)%6,(varoffset-3760)/240,
#ifdef RUN_IN_BOARD
                                                  dataHandler->getRecvVarValueByOffset(comidIndex,328+(varoffset-3760)/10,0),
#else
                                                  0xFFFFFFFF,
#endif
                                                 value);
        else if(varoffset >= 4340 && varoffset <= 4440)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_PM25,(varoffset-4340)/20,value);
        else if(varoffset >= 4460 && varoffset <= 4560)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_CO2,(varoffset-4460)/20,value);
        else if(varoffset >= 4580 && varoffset <= 4680)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_TVOC,(varoffset-4580)/20,value);
        else if(varoffset >= 4700 && varoffset <= 4800)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_PressureDifference,(varoffset-4700)/20,value);
        else if(varoffset >= 4820 && varoffset <= 4870)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_Humidity,(varoffset-4820)/10,value);
        else if(varoffset >= 4880 && varoffset <= 4930)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_SalTemp,(varoffset-4880)/10,value);
        else if(varoffset >= 5000 && varoffset <= 5050)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_UnitStat,((varoffset-5000)/10)*2,value);
        else if(varoffset >= 5060 && varoffset <= 5110)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_UnitStat,((varoffset-5060)/10)*2+1,value);
        else if(varoffset >= 4940 && varoffset <= 4990)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_TargetTemp,(varoffset-4940)/10,value);
        else if(varoffset >= 5120 && varoffset <= 5170)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_ControlMode,(varoffset-5120)/10,value);
        else if(varoffset >= 5180 && varoffset <= 5230)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_LowerLoad,(varoffset-5180)/10,value);
        else if(varoffset >= 5240 && varoffset <= 5290)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_NADamper,((varoffset-5240)/10)*4,value);
        else if(varoffset >= 5300 && varoffset <= 5350)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_NADamper,((varoffset-5300)/10)*4+1,value);
        else if(varoffset >= 5360 && varoffset <= 5410)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_NADamper,((varoffset-5360)/10)*4+2,value);
        else if(varoffset >= 5420 && varoffset <= 5470)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_NADamper,((varoffset-5420)/10)*4+3,value);
        else if(varoffset >= 5480 && varoffset <= 5530)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_RADamper,((varoffset-5480)/10)*2,value);
        else if(varoffset >= 5540 && varoffset <= 5590)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_RADamper,((varoffset-5540)/10)*2+1,value);
        else if(varoffset >= 5600 && varoffset <= 5650)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_Compressor,((varoffset-5600)/10)*4,value);
        else if(varoffset >= 5660 && varoffset <= 5710)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_Compressor,((varoffset-5660)/10)*4+1,value);
        else if(varoffset >= 5720 && varoffset <= 5770)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_Compressor,((varoffset-5720)/10)*4+2,value);
        else if(varoffset >= 5780 && varoffset <= 5830)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_Compressor,((varoffset-5780)/10)*4+3,value);
        else if(varoffset >= 5840 && varoffset <= 5890)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_Condenserfan,((varoffset-5840)/10)*4,value);
        else if(varoffset >= 5900 && varoffset <= 5950)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_Condenserfan,((varoffset-5900)/10)*4+1,value);
        else if(varoffset >= 5960 && varoffset <= 6010)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_Condenserfan,((varoffset-5960)/10)*4+2,value);
        else if(varoffset >= 6020 && varoffset <= 6070)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_Condenserfan,((varoffset-6020)/10)*4+3,value);
        else if(varoffset >= 6080 && varoffset <= 6130)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_Ventor,((varoffset-6080)/10)*4,value);
        else if(varoffset >= 6140 && varoffset <= 6190)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_Ventor,((varoffset-6140)/10)*4+1,value);
        else if(varoffset >= 6200 && varoffset <= 6250)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_Ventor,((varoffset-6200)/10)*4+2,value);
        else if(varoffset >= 6260 && varoffset <= 6310)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_Ventor,((varoffset-6260)/10)*4+3,value);
        else if(varoffset >= 6320 && varoffset <= 6420)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_HVAC,(varoffset-6300)/20,value,16,"8.8");
        else if(varoffset == 6440)
            tcms_hvac_->syncHVACMode(value);
        else if(varoffset >= 6450 && varoffset <= 6500)
            tcms_hvac_->syncHVACTemp((varoffset-6440)/10,value);
        else if(varoffset == 6510)
            tcms_hvac_->syncHVACTemp(0,value);
        else if(varoffset == 6560)
            tcms_maint_door_para_set_->setDelOpen(value);
        else if(varoffset == 6580)
            tcms_maint_door_para_set_->setDelClose(value);
        else if(varoffset == 6600)
            tcms_maint_door_para_set_->setOpenTime(value);
        else if(varoffset == 6620)
            tcms_maint_door_para_set_->setCloseTime(value);
        else if(varoffset == 6640)
            tcms_maint_door_para_set_->setObstNumb(value);
        else if(varoffset == 6660)
            tcms_maint_door_para_set_->setOpenWidthObst(value);
        else if(varoffset == 6680)
            tcms_maint_door_para_set_->setSusTimObst(value);
        else if(varoffset == 6700)
            tcms_maint_door_para_set_->setFinOpenWidthObst(value);
        else if(varoffset == 6720)
            tcms_maint_door_para_set_->setAppTimObst(value);
        else if(varoffset >= 6740 && varoffset <= 6820)
            tcms_maint_door_para_set_->setTightClose((varoffset-6740)/20,value);
        else if(varoffset >= 6840 && varoffset <= 6850)
            tcms_bypass_->setBypassStat(PageBypass::BYPASS_DBPS,(varoffset-6840)/10,value);
        else if(varoffset >= 6860 && varoffset <= 7800)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_EDCU1+((varoffset-6860)/20)%8,
                                               ((varoffset-6860)/20)/8+1,
                                               value,16,"8.8");
        else if(varoffset >= 7820 && varoffset <= 8290 )
            tcms_operation_->train()->setSaloonDorStat(((varoffset-7820)/10)/8,((varoffset-7820)/10)%8,value);
        else if(varoffset >= 8360 && varoffset <= 8590 )
        {
            tcms_operation_->train()->setPECUStatus(((varoffset-8360)/10)/4,((varoffset-8360)/10)%4,value);
            tcms_pecu_stat_->setPECUStat((varoffset-8360)/10,value);
        }
        else if(varoffset == 8660)
        {
            tcms_pis_mode_set_->syncPisMode(value-1);
            GlobalConfig::PISMode = value-1;
            tcms_operation_->setPisMannualBtnsActive(GlobalConfig::PISMode == PIS_ModeMannual);
        }
        else if(varoffset == 8670)
            tcms_pis_mode_set_->syncLineDirection(value);
        else if(varoffset == 8700)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_PIC,1,value,16,"8.8");
        else if(varoffset == 8720)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_PIC,6,value,16,"8.8");
        else if(varoffset == 8740)
            toptitle_->setEndStation(value);
        else if(varoffset == 8760)
            toptitle_->setNextStation(value);
        else if(varoffset == 8780)
            toptitle_->setCurStation(value);
        else if(varoffset == 8800)
            toptitle_->setSpeedLimt(value);
        else if(varoffset >= 8810 && varoffset <= 8820)
        {
            static int cab1stat = 0;
            static int cab2stat = 0;
            if(varoffset == 8810)
                cab1stat = value;
            else if(varoffset == 8820)
                cab2stat = value;
            tcms_operation_->train()->setCabStat(0,cab1stat);
            tcms_operation_->train()->setCabStat(1,cab2stat);
            if(cab1stat == 1)
                GlobalConfig::cabActivated = 1;
            else if(cab2stat == 1)
                GlobalConfig::cabActivated = 6;
            else
                GlobalConfig::cabActivated = 0;
            tcms_operation_->train()->setDirection(GlobalConfig::runDirection);
            GlobalConfig::xLocalActive = GlobalConfig::cabActivated==GlobalConfig::cabNumber;
            setPagesActive(GlobalConfig::xLocalActive && !GlobalConfig::xFAM);
            setPisPageActive(GlobalConfig::xLocalActive &&!GlobalConfig::xFAM &&GlobalConfig::xZeroSpeed);
        }
        else if(varoffset == 8840)
        {
            toptitle_->setTrainSpeed(value);
            GlobalConfig::xZeroSpeed = (value == 0);
            setPisPageActive(GlobalConfig::xLocalActive &&!GlobalConfig::xFAM &&GlobalConfig::xZeroSpeed);
        }
        else if(varoffset == 8860)
        {
            GlobalConfig::runDirection = value;
            tcms_operation_->train()->setDirection(value);
        }
        else if(varoffset == 8870)
        {
            toptitle_->setDriveMode(value);
            GlobalConfig::xFAM = (value == 6);
            setPagesActive(GlobalConfig::xLocalActive && !GlobalConfig::xFAM);
            setPisPageActive(GlobalConfig::xLocalActive &&!GlobalConfig::xFAM &&GlobalConfig::xZeroSpeed);
        }
        else if(varoffset == 8880)
            toptitle_->setTrainStat(value);
        else if(varoffset == 8900)
            tcms_maint_speed_test_->setTestStartSpeed(PageSpeedTest::SPeedTest_PRO,value);
        else if(varoffset == 8920)
            tcms_maint_speed_test_->setTestDistance(PageSpeedTest::SPeedTest_PRO,value);
        else if(varoffset == 8940)
            tcms_maint_speed_test_->setTestDuration(PageSpeedTest::SPeedTest_PRO,value);
        else if(varoffset == 8960)
            tcms_maint_speed_test_->setTestEndSpeed(PageSpeedTest::SPeedTest_PRO,value);
        else if(varoffset == 8980)
            tcms_maint_speed_test_->setAcceleration(PageSpeedTest::SPeedTest_PRO,value);
        else if(varoffset == 8990)
            tcms_maint_speed_test_->setAcceleration(PageSpeedTest::SpeedTest_BRK,value);
        else if(varoffset == 9000)
            tcms_maint_speed_test_->setTestStartSpeed(PageSpeedTest::SpeedTest_BRK,value);
        else if(varoffset == 9020)
            tcms_maint_speed_test_->setTestDistance(PageSpeedTest::SpeedTest_BRK,value);
        else if(varoffset == 9040)
            tcms_maint_speed_test_->setTestDuration(PageSpeedTest::SpeedTest_BRK,value);
        else if(varoffset == 9060)
            tcms_maint_speed_test_->setTestEndSpeed(PageSpeedTest::SpeedTest_BRK,value);
        else if(varoffset == 9120)
            tcms_maint_accumlations_->setDayDistance(value);
        else if(varoffset == 9160)
            tcms_maint_accumlations_->setTotalDistance(value);
        else if(varoffset >= 9200 && varoffset <= 9210)
            tcms_bypass_->setBypassStat(PageBypass::BYPASS_DMBPS,(varoffset-9200)/10,value);
        else if(varoffset == 9220)
            tcms_speed_limit_->setEDFltCount(value);
        else if(varoffset == 9230)
            tcms_speed_limit_->setEPFltCount(value);
        else if(varoffset == 9240)
            tcms_speed_limit_->setTracFltCount(value);
        else if(varoffset >= 9250 && varoffset <= 9260)
            tcms_bypass_->setBypassStat(PageBypass::BYPASS_BDMS,(varoffset-9250)/10,value);
        else if(varoffset >= 9270 && varoffset <= 9280)
            tcms_bypass_->setBypassStat(PageBypass::BYPASS_HTS,(varoffset-9270)/10,value);
        else if(varoffset == 9320)
            tcms_maint_accumlations_->setHVACEnergyConsume(value);
        else if(varoffset >= 9360 && varoffset <= 9460)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_EnergyMonth1,(varoffset-9360)/20,value);
        else if(varoffset >= 9480 && varoffset <= 9580)
            tcms_hvac_->setHVACStat(PageHvac::HVACStat_EnergyMonth2,(varoffset-9480)/20,value);
        else if(varoffset == 9600)
            tcms_pis_skip_station_set_->SyncFeedBackSkipStations(value);
        else if(varoffset >= 9660 && varoffset <= 9670)
            tcms_bypass_->setBypassStat(PageBypass::ByPASS_EBBPK,(varoffset-9660)/10,value);
        break;
    case 2:
        if(varoffset >= 0 && varoffset <= 10)
            tcms_maint_man_self_test_->setBrkManSelfTestStat(varoffset/10,value);
        else if(varoffset >= 100 && varoffset <= 110)
            tcms_brake_stat_->setBrkStat(PageBrake::BrkStat_MainRes,(varoffset-100)/10,value);
        else if(varoffset >= 140 && varoffset <= 150)
            tcms_operation_->train()->setAirCompressorStat((varoffset-140)/10,value);
        else if(varoffset >= 160 && varoffset <= 200)
            tcms_maint_accumlations_->setTotalACRunTime((varoffset-160)/40,value);
        else if(varoffset >= 390 && varoffset <= 440)
            tcms_brake_stat_->setBrkStat(PageBrake::BrkStat_LoadFactor,(varoffset-390)/10,value);
        else if(varoffset >= 450 && varoffset <= 560)
            tcms_operation_->train()->setServiceBrkStat(((varoffset-450)/10)/2,((varoffset-450)/10)%2,value);
        else if(varoffset >= 570 && varoffset <= 680)
            tcms_brake_stat_->setBrkStat(PageBrake::BrkStat_AirSuspPress,(varoffset-570)/10,value);
        else if(varoffset >= 690 && varoffset <= 800)
            tcms_brake_stat_->setBrkStat(PageBrake::BrkStat_BCPB,(varoffset-690)/10,value);
        else if(varoffset >= 810 && varoffset <= 860)
            tcms_operation_->train()->setParkingBrakeStat((varoffset-810)/10,value);
        else if(varoffset >= 870 && varoffset <= 920)
            tcms_brake_stat_->setBrkStat(PageBrake::BrkStat_PBPress,(varoffset-870)/10,value);
        else if(varoffset >= 940 && varoffset <= 1040)
            tcms_brake_stat_->setBrkStat(PageBrake::BrkStat_LocWeight,(varoffset-940)/20,value);
        else if(varoffset >= 1060 && varoffset <= 1070)
            tcms_bypass_->setBypassStat(PageBypass::BYPASS_LMRGBS,(varoffset-1060)/10,value);
        else if(varoffset >= 1080 && varoffset <= 1090)
            tcms_bypass_->setBypassStat(PageBypass::BYPASS_PBRBS,(varoffset-1080)/10,value);
        else if(varoffset >= 1100 && varoffset <= 1110)
            tcms_bypass_->setBypassStat(PageBypass::BYPASS_ABRBS,(varoffset-1100)/10,value);
        else if(varoffset == 1120)
            tcms_brake_stat_->setBrkStat(PageBrake::BrkStat_Master,0,value);
        else if(varoffset == 1130)
            tcms_brake_stat_->setBrkStat(PageBrake::BrkStat_Master,2,value);
        else if(varoffset == 1140)
            tcms_brake_stat_->setBrkStat(PageBrake::BrkStat_Master,3,value);
        else if(varoffset == 1150)
            tcms_brake_stat_->setBrkStat(PageBrake::BrkStat_Master,5,value);
        else if(varoffset >= 1160 && varoffset <= 1170)
            tcms_brake_stat_->setBrkStat(PageBrake::BrkStat_HoldBrk,(varoffset-1160)/10,value);
        else if(varoffset == 1180)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_BCU,1,value,16,"8.8");
        else if(varoffset == 1200)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_BCU,3,value,16,"8.8");
        else if(varoffset == 1220)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_BCU,4,value,16,"8.8");
        else if(varoffset == 1240)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_BCU,6,value,16,"8.8");
        else if(varoffset == 1260)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_DDUR,1,value,16,"4.4.8");
        else if(varoffset == 1280)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_DDUR,6,value,16,"4.4.8");
        else if(varoffset >= 1400 && varoffset <= 1410)
            tcms_bypass_->setBypassStat(PageBypass::BYPASS_OBS,(varoffset-1400)/10,value);
        else if(varoffset >= 1420 && varoffset <= 1430)
            tcms_bypass_->setBypassStat(PageBypass::BYPASS_HLIS,(varoffset-1420)/10,value);
        else if(varoffset == 1440)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_BMS,1,value,8,"0");
        else if(varoffset == 1450)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_BMS,6,value,8,"0");
        else if(varoffset >= 1460 && varoffset <= 1540)
            tcms_battery_stat_->setBatStat(PageBattery::BAT_Volt+(varoffset-1460)/20,0,value);
        else if(varoffset >= 1560 && varoffset <= 1570)
            tcms_battery_stat_->setBatStat(PageBattery::BAT_UnconNum+(varoffset-1560)/10,0,value);
        else if(varoffset >= 1580 && varoffset <= 1660)
            tcms_battery_stat_->setBatStat(PageBattery::BAT_Volt+(varoffset-1580)/20,5,value);
        else if(varoffset >= 1680 && varoffset <= 1690)
            tcms_battery_stat_->setBatStat(PageBattery::BAT_UnconNum+(varoffset-1680)/10,5,value);
        else if(varoffset >= 1700 && varoffset <= 2520)
            tcms_maint_battery_->setBatCoreVolt(0,(varoffset-1700)/20,value);
        else if(varoffset >= 2540 && varoffset <= 2760)
            tcms_maint_battery_->setBatCoreTemp(0,(varoffset-2540)/20,value);
        else if(varoffset >= 2780 && varoffset <= 3600)
            tcms_maint_battery_->setBatCoreVolt(1,(varoffset-2780)/20,value);
        else if(varoffset >= 3620 && varoffset <= 3840)
            tcms_maint_battery_->setBatCoreTemp(1,(varoffset-3620)/20,value);
        else if(varoffset >= 3860 && varoffset <= 3890)
            tcms_maint_wheel_set_->setProWheelValue((varoffset-3860)/10,value);
        else if(varoffset >= 3900 && varoffset <= 3910)
            tcms_maint_wheel_set_->setBrkWheelValue((varoffset-3900)/10,value);
        else if(varoffset >= 3920 && varoffset <= 3940)
        {
            uint32_t ver = 0;
#ifdef RUN_IN_BOARD
            ver = (dataHandler->getRecvVarValueByOffset(comidIndex,392,0) << 16)+
                  (dataHandler->getRecvVarValueByOffset(comidIndex,393,0) << 8 )+
                  dataHandler->getRecvVarValueByOffset(comidIndex,394,0) ;
#endif
            tcms_maint_version_->setDevVersion(PageVersion::Ver_ACE,1,ver,24,"8.8.8");
        }
        else if(varoffset >= 3950 && varoffset <= 3970)
        {
            uint32_t ver = 0;
#ifdef RUN_IN_BOARD
            ver = (dataHandler->getRecvVarValueByOffset(comidIndex,395,0) << 16)+
                  (dataHandler->getRecvVarValueByOffset(comidIndex,396,0) << 8) +
                  dataHandler->getRecvVarValueByOffset(comidIndex,397,0) ;
#endif
            tcms_maint_version_->setDevVersion(PageVersion::Ver_ACE,3,ver,24,"8.8.8");
        }
        else if(varoffset >= 3980 && varoffset <= 4000)
        {
            uint32_t ver = 0;
#ifdef RUN_IN_BOARD
            ver = (dataHandler->getRecvVarValueByOffset(comidIndex,398,0) << 16)+
                  (dataHandler->getRecvVarValueByOffset(comidIndex,399,0) << 8) +
                  dataHandler->getRecvVarValueByOffset(comidIndex,400,0) ;
#endif
            tcms_maint_version_->setDevVersion(PageVersion::Ver_ACE,4,ver,24,"8.8.8");
        }
        else if(varoffset >= 4010 && varoffset <= 4030)
        {
            uint32_t ver = 0;
#ifdef RUN_IN_BOARD
            ver = (dataHandler->getRecvVarValueByOffset(comidIndex,401,0) << 16)+
                  (dataHandler->getRecvVarValueByOffset(comidIndex,402,0) << 8) +
                  dataHandler->getRecvVarValueByOffset(comidIndex,403,0) ;
#endif
            tcms_maint_version_->setDevVersion(PageVersion::Ver_ACE,6,ver,24,"8.8.8");
        }
        else if(varoffset >= 4040 && varoffset <= 4060)
        {
            uint32_t ver = 0;
#ifdef RUN_IN_BOARD
            ver = (dataHandler->getRecvVarValueByOffset(comidIndex,404,0) << 16)+
                  (dataHandler->getRecvVarValueByOffset(comidIndex,405,0) << 8) +
                  dataHandler->getRecvVarValueByOffset(comidIndex,406,0) ;
#endif
            tcms_maint_version_->setDevVersion(PageVersion::Ver_PCE,2,ver,24,"8.8.8");
        }
        else if(varoffset >= 4070 && varoffset <= 4090)
        {
            uint32_t ver = 0;
#ifdef RUN_IN_BOARD
            ver = (dataHandler->getRecvVarValueByOffset(comidIndex,407,0) << 16)+
                  (dataHandler->getRecvVarValueByOffset(comidIndex,408,0) << 8) +
                  dataHandler->getRecvVarValueByOffset(comidIndex,409,0) ;
#endif
            tcms_maint_version_->setDevVersion(PageVersion::Ver_PCE,3,ver,24,"8.8.8");
        }
        else if(varoffset >= 4100 && varoffset <= 4120)
        {
            uint32_t ver = 0;
#ifdef RUN_IN_BOARD
            ver = (dataHandler->getRecvVarValueByOffset(comidIndex,410,0) << 16)+
                  (dataHandler->getRecvVarValueByOffset(comidIndex,411,0) << 8) +
                  dataHandler->getRecvVarValueByOffset(comidIndex,412,0) ;
#endif
            tcms_maint_version_->setDevVersion(PageVersion::Ver_PCE,4,ver,24,"8.8.8");
        }
        else if(varoffset >= 4130 && varoffset <= 4150)
        {
            uint32_t ver = 0;
#ifdef RUN_IN_BOARD
            ver = (dataHandler->getRecvVarValueByOffset(comidIndex,413,0) << 16)+
                  (dataHandler->getRecvVarValueByOffset(comidIndex,414,0) << 8) +
                  dataHandler->getRecvVarValueByOffset(comidIndex,415,0) ;
#endif
            tcms_maint_version_->setDevVersion(PageVersion::Ver_PCE,5,ver,24,"8.8.8");
        }
        else if(varoffset == 4160)
            tcms_aux_stat_->setAuxStat(5,0,value);
        else if(varoffset == 4180)
            tcms_aux_stat_->setAuxStat(5,2,value);
        else if(varoffset == 4200)
            tcms_aux_stat_->setAuxStat(5,3,value);
        else if(varoffset == 4220)
            tcms_aux_stat_->setAuxStat(5,5,value);
        else if(varoffset == 4240)
            tcms_aux_stat_->setAuxStat(6,0,value);
        else if(varoffset == 4260)
            tcms_aux_stat_->setAuxStat(6,2,value);
        else if(varoffset == 4280)
            tcms_aux_stat_->setAuxStat(6,3,value);
        else if(varoffset == 4300)
            tcms_aux_stat_->setAuxStat(6,5,value);
        else if(varoffset == 4320)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_ICDS,2,value,16,"8.8");
        else if(varoffset == 4340)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_ICDS,5,value,16,"8.8");
        else if(varoffset >= 4360 && varoffset <= 4370)
            tcms_fire_stat_->setSHDStat(0,(varoffset-4360)/10+5,value);
        else if(varoffset >= 4380 && varoffset <= 4390)
            tcms_fire_stat_->setSHDStat(5,(varoffset-4380)/10+5,value);
        else if(varoffset == 4400)
            tcms_battery_stat_->setBatStat(PageBattery::BAT_hydrogen,0,value);
        else if(varoffset == 4420)
            tcms_battery_stat_->setBatStat(PageBattery::BAT_hydrogen,5,value);
        else if(varoffset >= 7000 && varoffset <= 9353)
            mapToInterface(comidIndex,varoffset,value);
        break;
    case 3:
        if((varoffset >= 0 && varoffset <= 6907) || (varoffset >= 6964 && varoffset <= 7002))
            mapToEvent(comidIndex,varoffset,value);

        if(varoffset == 15)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest22_1,value);
        else if(varoffset == 16)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest2_1,value);
        else if(varoffset == 17)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_HVS,value);
        else if(varoffset == 20)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest22_6,value);
        else if(varoffset == 21)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest2_6,value);
        else if(varoffset >= 23 && varoffset <= 27)
            tcms_operation_->train()->setFireStat(varoffset-23,value);
        else if(varoffset == 30)
            tcms_operation_->train()->setFireStat(5,value);
        else if(varoffset == 31)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_FAU,value);
        else if(varoffset >= 32 && varoffset <= 33)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_FCU,varoffset-32,value);
        else if(varoffset == 240)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_ECR,value);
        else if(varoffset >= 241 && varoffset <= 242)
        {
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_ECR,varoffset-241,value);
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_ECR,varoffset-241,value);
        }
        else if(varoffset >= 261 && varoffset <= 264)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_ACE,varoffset-261,value);
        else if(varoffset == 707)
            tcms_operation_->train()->setACModeStat(0,value);
        else if(varoffset == 710)
            tcms_operation_->train()->setACModeStat(1,value);
        else if(varoffset == 711)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_AUX,value);
        else if(varoffset == 712)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest1_1,value);
        else if(varoffset == 713)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest1_6,value);
        else if(varoffset == 716)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_TCDS,0,value);
        else if(varoffset == 720)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_TCDS,value);
        else if(varoffset == 733)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_LCU,value);
        else if(varoffset >= 734 && varoffset <= 741)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_LCU,indexOfoffset(varoffset)-indexOfoffset(734),value);
        else if(varoffset == 1191)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_PRO,value);
        else if(varoffset >= 1192 && varoffset <= 1195)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_PCE,varoffset-1192,value);
        else if(varoffset >= 1256 && varoffset <= 1270)
            tcms_traction_block_->setTBTrigStat(indexOfoffset(varoffset)-indexOfoffset(1256),value);
        else if(varoffset == 1271)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest13_1,value);
        else if(varoffset == 1272)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest15_1,value);
        else if(varoffset == 1273)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest16_1,value);
        else if(varoffset == 1274)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest13_6,value);
        else if(varoffset == 1275)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest15_6,value);
        else if(varoffset == 1276)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest16_6,value);
        else if(varoffset >= 1794 && varoffset <= 1795)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_ATC,varoffset-1794,value);
        else if(varoffset >= 1800 && varoffset <= 1801)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_VCU,varoffset-1800,value
#ifdef RUN_IN_BOARD
                                                    ,dataHandler->getRecvVarValueByOffset(comidIndex,189,varoffset-1800+2));
#else
                                                    );
#endif
        else if(varoffset >= 1802 && varoffset <= 1803)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_DDU,varoffset-1802,value);
        else if(varoffset >= 1804 && varoffset <= 1805)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_VSCU,varoffset-1804,value
#ifdef RUN_IN_BOARD
                                                    ,dataHandler->getRecvVarValueByOffset(comidIndex,189,varoffset-1804+4));
#else
                                                    );
#endif
        else if(varoffset >= 1806 && varoffset <= 1807)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_RIOM10,varoffset-1806,value);
        else if(varoffset >= 1810 && varoffset <= 1812)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_EVR,varoffset-1810,value);
        else if(varoffset == 1891)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_TCMS,value);
        else if(varoffset >= 1892 && varoffset <= 1893)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_VCU,varoffset-1892,
#ifdef RUN_IN_BOARD
                                                    dataHandler->getRecvVarValueByOffset(comidIndex,180,varoffset-1892),
#else
                                                    0,
#endif
                                                    value);
        else if(varoffset >= 1894 && varoffset <= 1895)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_VSCU,varoffset-1894,
#ifdef RUN_IN_BOARD
                                                    dataHandler->getRecvVarValueByOffset(comidIndex,180,varoffset-1894+4),
#else
                                                    0,
#endif
                                                    value);
        else if(varoffset == 1931)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest4_1,value);
        else if(varoffset == 1932)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest4_6,value);
        else if(varoffset == 1933)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_HVAC,value);
        else if(varoffset >= 1934 && varoffset <= 1941)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_HVAC,indexOfoffset(varoffset)-indexOfoffset(1934),value);
        else if(varoffset >= 2560 && varoffset <= 2567)
            tcms_speed_limit_->setSpeedlimtReason(varoffset-2560,value);
        else if(varoffset == 2570)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_DRV,value);
        else if(varoffset == 2580)
        {
            stopbeep();
            if(value == 1)
                beep(true);
        }
//        else if(varoffset == 2604)
//        {
//            if(GlobalConfig::cabNumber==1)
//                setBeepEnable(value);
//        }
//        else if(varoffset == 2605)
//        {
//            if(GlobalConfig::cabNumber==6)
//                setBeepEnable(value);
//        }
        else if(varoffset == 2656)
            toptitle_->setMaintMode(value);
        else if(varoffset >= 2666 && varoffset <= 2844)
        {
            tcms_maint_key_cbs_->setCiruitBreakStat(comidIndex*10000+varoffset,value);
            if(varoffset == 2762)
                tcms_maint_pis_breaker_test_->setPISBreakStat(0,value);
            else if(varoffset == 2763)
                tcms_maint_pis_breaker_test_->setPISBreakStat(1,value);
            else if(varoffset == 2764)
                tcms_maint_pis_breaker_test_->setPISBreakStat(2,value);
            else if(varoffset == 2765)
                tcms_maint_pis_breaker_test_->setPISBreakStat(7,value);
            else if(varoffset == 2810)
                tcms_maint_pis_breaker_test_->setPISBreakStat(3,value);
            else if(varoffset == 2811)
                tcms_maint_pis_breaker_test_->setPISBreakStat(6,value);
            else if(varoffset == 2844)
                tcms_maint_pis_breaker_test_->setPISBreakStat(4,value);
            else if(varoffset == 2845)
                tcms_maint_pis_breaker_test_->setPISBreakStat(5,value);

            if(varoffset == 2710)
                tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest18_1,value);
            else if(varoffset == 2711)
                tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest18_6,value);
        }
        else if(varoffset >= 2914 && varoffset <= 2917)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_BCU,varoffset-2914,value);
        else if(varoffset == 2920)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest3_1,value);
        else if(varoffset == 2921)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest3_6,value);
        else if(varoffset >= 2937 && varoffset <= 2964)
            tcms_eb_reason_->setEBTrigStat(indexOfoffset(varoffset)-indexOfoffset(2937),value);
        else if(varoffset >= 2997 && varoffset <= 3004)
            tcms_operation_->train()->setIdlingStat(indexOfoffset(varoffset)-indexOfoffset(2997),value);
        else if(varoffset >= 3005 && varoffset <= 3012)
            tcms_operation_->train()->setSlipingStat(indexOfoffset(varoffset)-indexOfoffset(3005),value);
        else if(varoffset == 3014)
            tcms_maint_clean_brake_->setCleanBrakeStat(value);
        else if(varoffset == 3017)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest11_1,value);
        else if(varoffset == 3020)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest8_1,value);
        else if(varoffset == 3021)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest5_1,value);
        else if(varoffset == 3022)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest9_1,value);
        else if(varoffset == 3023)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest10_1,value);
        else if(varoffset == 3024)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest14_1,value);
        else if(varoffset == 3025)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest6_1,value);
        else if(varoffset == 3026)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest12_1,value);
        else if(varoffset == 3027)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest7_1,value);
        else if(varoffset == 3030)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest11_6,value);
        else if(varoffset == 3031)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest8_6,value);
        else if(varoffset == 3032)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest5_6,value);
        else if(varoffset == 3033)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest9_6,value);
        else if(varoffset == 3034)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest10_6,value);
        else if(varoffset == 3035)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest14_6,value);
        else if(varoffset == 3036)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest6_6,value);
        else if(varoffset == 3037)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest12_6,value);
        else if(varoffset == 3040)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest7_6,value);
        else if(varoffset == 3041)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_BRK,value);
        else if(varoffset >= 3773 && varoffset <= 3786)
        {
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_EDCU,indexOfoffset(varoffset)-indexOfoffset(3773),value);
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_EDCU,indexOfoffset(varoffset)-indexOfoffset(3773),value);
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_EDCU,indexOfoffset(varoffset)-indexOfoffset(3773),value);
        }
        else if(varoffset == 5157)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_DOR,value);
        else if(varoffset >= 5160 && varoffset <= 5162)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest19_1+varoffset-5160,value);
        else if(varoffset >= 5163 && varoffset <= 5165)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest19_6+varoffset-5163,value);
        else if(varoffset >= 5175 && varoffset <= 5176)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_PIC,varoffset-5175,value
#ifdef RUN_IN_BOARD
                                                    ,dataHandler->getRecvVarValueByOffset(comidIndex,541,varoffset-5175+1));
#else
                                                    );
#endif
        else if(varoffset >= 5411 && varoffset <= 5412)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_PIC,varoffset-5411,
#ifdef RUN_IN_BOARD
                                                    dataHandler->getRecvVarValueByOffset(comidIndex,517,varoffset-5411+5),
#else
                                                    0,
#endif
                                                    value);
        else if(varoffset == 5413)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_PIS,value);
        else if(varoffset == 5414)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_GPIS,value);
        else if(varoffset == 5415)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_RADIO,value);
        else if(varoffset == 5416)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest17_1,value);
        else if(varoffset == 5417)
            tcms_self_test_->setOPStaticSelfTestFailStat(PageSelfTest::OP_SELFTEST_StatcTest17_6,value);
        else if(varoffset == 5502)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_LGT,value);
        else if(varoffset == 5507)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_BMS,value);
        else if(varoffset >= 5510 && varoffset <= 5511)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_BMS,varoffset-5510,value);
        else if(varoffset == 5564)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_ODS,value);
        else if(varoffset == 5565)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_ICDS,value);
        else if(varoffset == 5566)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_BDS,value);
        else if(varoffset == 5567)
            tcms_self_test_->setOPSelfTestStat(PageSelfTest::OP_SELFTEST_PANMS,value);
        else if(varoffset >= 5570 && varoffset <= 5571)
            tcms_maint_network_->setDeviceComStatus(Network_BlueAndRed,PageNetwork::TOPO_ICDS,varoffset-5570,value);
        else if(varoffset >= 6770 && varoffset <= 6771)
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_FCU,varoffset-6770,value);
        else if(varoffset >= 6772 && varoffset <= 6775)
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_ACE,varoffset-6772,value);
        else if(varoffset >= 6776 && varoffset <= 6783)
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_LCU,indexOfoffset(varoffset)-indexOfoffset(6776),value);
        else if(varoffset >= 6784 && varoffset <= 6787)
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_PCE,varoffset-6784,value);
        else if(varoffset >= 6790 && varoffset <= 6791)
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_ATC,varoffset-6790,value);
        else if(varoffset >= 6792 && varoffset <= 6793)
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_VCU,varoffset-6792,value);
        else if(varoffset >= 6794 && varoffset <= 6795)
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_DDU,varoffset-6794,value);
        else if(varoffset >= 6796 && varoffset <= 6797)
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_VSCU,varoffset-6796,value);
        else if(varoffset >= 6800 && varoffset <= 6801)
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_RIOM10,varoffset-6800,value);
        else if(varoffset >= 6802 && varoffset <= 6804)
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_EVR,varoffset-6802,value);
        else if(varoffset >= 6805 && varoffset <= 6812)
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_HVAC,indexOfoffset(varoffset)-indexOfoffset(6805),value);
        else if(varoffset >= 6813 && varoffset <= 6816)
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_BCU,varoffset-6813,value);
        else if(varoffset >= 6817 && varoffset <= 6820)
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_PIC,indexOfoffset(varoffset)-indexOfoffset(6817),value);
        else if(varoffset >= 6821 && varoffset <= 6822)
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_BMS,varoffset-6821,value);
        else if(varoffset >= 6825 && varoffset <= 6826)
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_ICDS,varoffset-6825,value);
        else if(varoffset == 6827)
            tcms_maint_network_->setDeviceComStatus(Network_Red,PageNetwork::TOPO_TCDS,0,value);
        else if(varoffset >= 6830 && varoffset <= 6831)
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_FCU,varoffset-6830,value);
        else if(varoffset >= 6832 && varoffset <= 6835)
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_ACE,varoffset-6832,value);
        else if(varoffset >= 6836 && varoffset <= 6843)
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_LCU,indexOfoffset(varoffset)-indexOfoffset(6836),value);
        else if(varoffset >= 6844 && varoffset <= 6847)
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_PCE,varoffset-6844,value);
        else if(varoffset >= 6850 && varoffset <= 6851)
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_ATC,varoffset-6850,value);
        else if(varoffset >= 6852 && varoffset <= 6853)
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_VCU,varoffset-6852,value);
        else if(varoffset >= 6854 && varoffset <= 6855)
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_DDU,varoffset-6854,value);
        else if(varoffset >= 6856 && varoffset <= 6857)
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_VSCU,varoffset-6856,value);
        else if(varoffset >= 6860 && varoffset <= 6861)
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_RIOM10,varoffset-6860,value);
        else if(varoffset >= 6862 && varoffset <= 6864)
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_EVR,varoffset-6862,value);
        else if(varoffset >= 6865 && varoffset <= 6872)
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_HVAC,indexOfoffset(varoffset)-indexOfoffset(6865),value);
        else if(varoffset >= 6873 && varoffset <= 6876)
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_BCU,varoffset-6873,value);
        else if(varoffset >= 6877 && varoffset <= 6880)
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_PIC,indexOfoffset(varoffset)-indexOfoffset(6877),value);
        else if(varoffset >= 6881 && varoffset <= 6882)
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_BMS,varoffset-6881,value);
        else if(varoffset >= 6885 && varoffset <= 6886)
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_ICDS,varoffset-6885,value);
        else if(varoffset == 6887)
            tcms_maint_network_->setDeviceComStatus(Network_Blue,PageNetwork::TOPO_TCDS,0,value);
        else if(varoffset == 6910)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest22_1,value);
        else if(varoffset == 6911)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest2_1,value);
        else if(varoffset == 6912)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest22_6,value);
        else if(varoffset == 6913)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest2_6,value);
        else if(varoffset == 6914)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest1_1,value);
        else if(varoffset == 6915)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest1_6,value);
        else if(varoffset == 6916)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest13_1,value);
        else if(varoffset == 6917)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest15_1,value);
        else if(varoffset == 6920)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest16_1,value);
        else if(varoffset == 6921)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest13_6,value);
        else if(varoffset == 6922)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest15_6,value);
        else if(varoffset == 6923)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest16_6,value);
        else if(varoffset == 6924)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest4_1,value);
        else if(varoffset == 6925)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest4_6,value);
        else if(varoffset == 6926)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest18_1,value);
        else if(varoffset == 6927)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest18_6,value);
        else if(varoffset == 6930)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest3_1,value);
        else if(varoffset == 6931)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest3_6,value);
        else if(varoffset == 6932)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest11_1,value);
        else if(varoffset == 6933)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest8_1,value);
        else if(varoffset == 6934)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest5_1,value);
        else if(varoffset == 6935)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest9_1,value);
        else if(varoffset == 6936)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest10_1,value);
        else if(varoffset == 6937)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest14_1,value);
        else if(varoffset == 6940)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest6_1,value);
        else if(varoffset == 6941)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest12_1,value);
        else if(varoffset == 6942)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest7_1,value);
        else if(varoffset == 6943)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest11_6,value);
        else if(varoffset == 6944)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest8_6,value);
        else if(varoffset == 6945)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest5_6,value);
        else if(varoffset == 6946)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest9_6,value);
        else if(varoffset == 6947)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest10_6,value);
        else if(varoffset == 6950)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest14_6,value);
        else if(varoffset == 6951)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest6_6,value);
        else if(varoffset == 6952)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest12_6,value);
        else if(varoffset == 6953)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest7_6,value);
        else if(varoffset == 6954)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest19_1,value);
        else if(varoffset == 6955)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest20_1,value);
        else if(varoffset == 6956)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest21_1,value);
        else if(varoffset == 6957)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest19_6,value);
        else if(varoffset == 6960)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest20_6,value);
        else if(varoffset == 6961)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest21_6,value);
        else if(varoffset == 6962)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest17_1,value);
        else if(varoffset == 6963)
            tcms_self_test_->setOPStaticSelfTestSuccessStat(PageSelfTest::OP_SELFTEST_StatcTest17_6,value);
        break;
    case 4:
        if(varoffset == 0)
        {
            tcms_operation_->atc_page()->set_M1_Stat(value);
            toptitle_->setATCSystemMode(value);
        }
        else if(varoffset == 4)
            tcms_operation_->atc_page()->set_M5_DoorStat(value);
        else if(varoffset == 10)
            tcms_operation_->atc_page()->set_M8_RightPSDStat(value);
        else if(varoffset == 12)
            tcms_operation_->atc_page()->set_M8_LeftPSDStat(value);
        else if(varoffset == 14)
            tcms_operation_->atc_page()->set_M10_LocationStat(value);
        else if(varoffset == 16)
            tcms_operation_->atc_page()->set_Sound_OverSpeed_Stat(value);
        else if(varoffset == 20)
            tcms_operation_->atc_page()->set_C2_CurrentPreSelectMode(value);
        else if(varoffset == 24)
            tcms_operation_->atc_page()->set_F_PreSelectStat(value);
        else if(varoffset == 30)
            tcms_operation_->atc_page()->set_M5_DoorOpenPermitMode(value);
        else if(varoffset == 34)
            tcms_operation_->atc_page()->set_M4_OutParkAreaStat(value);
        else if(varoffset == 36)
            tcms_operation_->atc_page()->set_M8_IdlingSlipStat(value);
        else if(varoffset == 40)
            tcms_operation_->atc_page()->set_M3_stat(value);
        else if(varoffset == 44)
            tcms_operation_->atc_page()->set_F_BackToDepotHint(value);
        else if(varoffset == 46)
            tcms_operation_->atc_page()->set_M10_DepotStat(value);
        else if(varoffset == 50)
            tcms_operation_->atc_page()->set_M2_CurrentRunLevel(value);
        else if(varoffset == 52)
            tcms_operation_->atc_page()->set_M5_DoorForcePermit(value);
        else if(varoffset == 62)
            tcms_operation_->atc_page()->set_M10_ReleaseSpeedStat(value);
        else if(varoffset == 63)
            tcms_operation_->atc_page()->set_M10_TrainFireStat(value);
        else if(varoffset == 64)
            tcms_operation_->atc_page()->set_F_SpeedReleaseStat(value);
        else if(varoffset == 66)
            tcms_operation_->atc_page()->set_F_ConfirmRunInRM(value);
        else if(varoffset == 72)
            tcms_operation_->atc_page()->set_C4_CutOffTractionStat(value);
        else if(varoffset == 74)
            tcms_operation_->atc_page()->set_C4_LackOfBrkEffortStat(value);
        else if(varoffset == 75)
            tcms_operation_->atc_page()->set_C4_RainAndSnowStat(value);
        else if(varoffset == 76)
            tcms_operation_->atc_page()->set_M8_EBStat(value);
        else if(varoffset == 81)
            tcms_operation_->atc_page()->set_F_EnterRainOrSnowMode(value);
        else if(varoffset == 82)
            tcms_operation_->atc_page()->set_C3_TrainIntegrityStat(value);
        else if(varoffset == 90)
            tcms_operation_->atc_page()->set_G3_ZCConnectionStat(value);
        else if(varoffset == 100)
            tcms_operation_->atc_page()->set_G3_CIConnectionStat(value);
        else if(varoffset == 110)
            tcms_operation_->atc_page()->set_G3_ATSConnectionStat(value);
        else if(varoffset == 130)
            tcms_operation_->atc_page()->set_C5_ATCDeviceStat(value);
        else if(varoffset == 140)
            tcms_operation_->atc_page()->set_M9_ATCSystemFltStat(value);
        else if(varoffset == 150)
            tcms_operation_->atc_page()->setEBCode(value);
        else if(varoffset == 190)
            tcms_operation_->atc_page()->Menu()->set_RCS_Test_Stat(value);
        else if(varoffset == 210)
            tcms_operation_->atc_page()->setTargetSpeed(value);
        else if(varoffset == 220)
            tcms_operation_->atc_page()->setTargetDistance(value);
        else if(varoffset == 240)
            tcms_operation_->atc_page()->setTrainSpeed(value);
        else if(varoffset == 250)
            tcms_operation_->atc_page()->setRestritSpeed(value);
        else if(varoffset == 260)
            tcms_operation_->atc_page()->setRecSpeedvalue(value);
        else if(varoffset == 340)
            tcms_operation_->atc_page()->set_M7_DoorControlMode(value);
        else if(varoffset == 342)
            tcms_operation_->atc_page()->set_M6_DepartHintStat(value);
        else if(varoffset == 350)
            tcms_operation_->atc_page()->set_N_ClearPassengersStat(value);
        else if(varoffset == 352)
            tcms_operation_->atc_page()->set_N_GoIndicationStat(value);
        else if(varoffset == 354)
            tcms_operation_->atc_page()->set_C1_ATOTracBrkStat(value);
        else if(varoffset == 360)
            tcms_operation_->atc_page()->set_N_NoGoIndicationStat(value);
        else if(varoffset == 364)
            tcms_operation_->atc_page()->set_M6_DoorCloseHintStat(value);
        else if(varoffset == 370)
            toptitle_->setDestinationID(value);
        else if(varoffset == 430)
            toptitle_->setTripID(value);
        else if(varoffset == 490)
            tcms_operation_->atc_page()->set_F_LocalTrainNumber(value);
        else if(varoffset == 530)
            tcms_operation_->atc_page()->set_F_TrainNumberErrorIndication(value);
        else if(varoffset == 540)
            tcms_operation_->atc_page()->set_F_VIDCheckStat(value);
        else if(varoffset == 550)
            toptitle_->setServiceID(value);
        else if(varoffset == 580)
            tcms_operation_->atc_page()->set_F_EBTestStat(value);
        else if(varoffset == 590)
            tcms_operation_->atc_page()->set_F_EBTestFailedCode(value);
        else if(varoffset == 600)
            tcms_operation_->atc_page()->indicate_F_EscapeDoorOpen(value);
        else if(varoffset == 601)
            tcms_operation_->atc_page()->indicate_F_SalDoorUnlocked(value);
        else if(varoffset == 602)
            tcms_operation_->atc_page()->indicate_F_RunTimeTooLong(value);
        else if(varoffset == 604)
            tcms_operation_->atc_page()->remind_F_DriverTakeOffKey(value);
        else if(varoffset == 606)
            tcms_operation_->atc_page()->set_F_ATPWakeUpFeedBackStat(value);
        else if(varoffset == 610)
            tcms_operation_->atc_page()->indicate_F_WheelCalibrationFail(value);
        else if(varoffset == 611)
            tcms_operation_->atc_page()->set_F_PassengerPullEmergencyHandle(value);
        else if(varoffset == 612)
            tcms_operation_->atc_page()->set_F_TrainSleepFailed(value);
        else if(varoffset == 614)
            tcms_operation_->atc_page()->indicate_F_QuitFAMMode(value);
        else if(varoffset == 616)
            tcms_operation_->atc_page()->indicate_F_UpGradeToFAMMode(value);
        else if(varoffset == 623)
            tcms_operation_->atc_page()->indicate_F_TempSpeedLimit(value);
        else if(varoffset == 624)
            tcms_operation_->atc_page()->set_F_BackWardSelect(value);
        else if(varoffset == 626)
            tcms_operation_->atc_page()->set_F_ForWardSelect(value);
        else if(varoffset == 630)
            tcms_operation_->atc_page()->set_N_DTITimeCountType(value);
        else if(varoffset == 640)
            tcms_operation_->atc_page()->set_N_DTITimeCount(value);
        else if(varoffset == 660)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_ATPSW,GlobalConfig::cabNumber==1?1:6,value,24,"8.8.8",false,HEX_Display);
        else if(varoffset == 690)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_ATPData,GlobalConfig::cabNumber==1?1:6,value,32,"8.8.8.8",false,HEX_Display);
        else if(varoffset == 730)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_ATOSW,GlobalConfig::cabNumber==1?1:6,value,24,"8.8.8",false,HEX_Display);
        else if(varoffset == 760)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_ATOData,GlobalConfig::cabNumber==1?1:6,value,32,"8.8.8.8",false,HEX_Display);
        else if(varoffset == 800)
            tcms_maint_version_->setDevVersion(PageVersion::Ver_AOMSW,GlobalConfig::cabNumber==1?1:6,value,24,"8.8.8",false,HEX_Display);
        else if(varoffset == 837)
            tcms_operation_->atc_page()->setUnReleasedEBStat(value);
        else if(varoffset == 860)
            tcms_operation_->atc_page()->set_C6_TrainStopDeviation(value);
    break;
    }
}

void MainWindow::executeCommand(const QString &command) {
    QProcess process;
    process.start(command);
    process.waitForFinished(-1); // 等待命令执行完毕
}

void MainWindow::setLocalDeviceIP_eth1(int trainnumer)
{
#ifdef RUN_IN_BOARD
    int board_id = 1;
    if(avic_get_currentBoardId()==1 && GlobalConfig::cabNumber == 1)
        board_id = 1;
    else if(avic_get_currentBoardId()==2 && GlobalConfig::cabNumber == 1)
        board_id = 2;
    else if(avic_get_currentBoardId()==1 && GlobalConfig::cabNumber == 6)
        board_id = 3;
    else if(avic_get_currentBoardId()==2 && GlobalConfig::cabNumber == 6)
        board_id = 4;
    // 修改设备eth1的IP地址
    executeCommand(QString("ifconfig eth1 10.80.%1.%2 netmask 255.255.255.0").arg(169+trainnumer).arg(132+board_id));
#endif
}

void MainWindow::slot_ManualChangeBoard(bool xChange)
{
    manual_change_ = xChange;
}
